Spaces:
Sleeping
Sleeping
| import streamlit as st | |
| import pandas as pd | |
| # Sample dummy data | |
| data = { | |
| "Country": ["Mexico", "Mexico", "Peru", "Peru", "Guatemala"], | |
| "Year": [2020, 2021, 2020, 2021, 2021], | |
| "Variable": ["Q1", "Q2", "Q3", "Q4", "Q5"], | |
| "Question": [ | |
| "How often do you visit a doctor?", | |
| "Do you trust the healthcare system?", | |
| "Have you received the COVID-19 vaccine?", | |
| "What is your primary source of news?", | |
| "Do you think education is affordable?" | |
| ], | |
| "Responses": [ | |
| "Never, Rarely, Sometimes, Often", | |
| "Yes, No", | |
| "Yes, No", | |
| "TV, Internet, Radio", | |
| "Yes, No" | |
| ] | |
| } | |
| df = pd.DataFrame(data) | |
| # Streamlit UI layout | |
| st.title("π CGD Survey Explorer (PoC)") | |
| st.sidebar.header("π Filter Questions") | |
| selected_country = st.sidebar.selectbox("Select Country", sorted(df["Country"].unique())) | |
| selected_year = st.sidebar.selectbox("Select Year", sorted(df["Year"].unique())) | |
| keyword = st.sidebar.text_input("Keyword Search", "") | |
| filtered = df[ | |
| (df["Country"] == selected_country) & | |
| (df["Year"] == selected_year) & | |
| (df["Question"].str.contains(keyword, case=False, na=False)) | |
| ] | |
| st.markdown(f"### Results for **{selected_country}** in **{selected_year}**") | |
| st.dataframe(filtered[["Variable", "Question", "Responses"]]) | |
| if filtered.empty: | |
| st.info("No matching questions found.") | |