Spaces:
Sleeping
Sleeping
Upload 3 files
Browse files- app.py +24 -0
- dummy_data.csv +6 -0
- requirements.txt +1 -2
app.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import streamlit as st
|
| 3 |
+
import pandas as pd
|
| 4 |
+
|
| 5 |
+
df = pd.read_csv("dummy_data.csv")
|
| 6 |
+
|
| 7 |
+
st.title("🌍 CGD Survey Explorer (PoC)")
|
| 8 |
+
|
| 9 |
+
st.sidebar.header("🔎 Filter Questions")
|
| 10 |
+
selected_country = st.sidebar.selectbox("Select Country", sorted(df["Country"].unique()))
|
| 11 |
+
selected_year = st.sidebar.selectbox("Select Year", sorted(df["Year"].unique()))
|
| 12 |
+
keyword = st.sidebar.text_input("Keyword Search", "")
|
| 13 |
+
|
| 14 |
+
filtered = df[
|
| 15 |
+
(df["Country"] == selected_country) &
|
| 16 |
+
(df["Year"] == selected_year) &
|
| 17 |
+
(df["Question"].str.contains(keyword, case=False, na=False))
|
| 18 |
+
]
|
| 19 |
+
|
| 20 |
+
st.markdown(f"### Results for **{selected_country}** in **{selected_year}**")
|
| 21 |
+
st.dataframe(filtered[["Variable", "Question", "Responses"]])
|
| 22 |
+
|
| 23 |
+
if filtered.empty:
|
| 24 |
+
st.info("No matching questions found.")
|
dummy_data.csv
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Country,Year,Variable,Question,Responses
|
| 2 |
+
Mexico,2020,Q1,How often do you visit a doctor?,"Never, Rarely, Sometimes, Often"
|
| 3 |
+
Mexico,2021,Q2,Do you trust the healthcare system?,"Yes, No"
|
| 4 |
+
Peru,2020,Q3,Have you received the COVID-19 vaccine?,"Yes, No"
|
| 5 |
+
Peru,2021,Q4,What is your primary source of news?,"TV, Internet, Radio"
|
| 6 |
+
Guatemala,2021,Q5,Do you think education is affordable?,"Yes, No"
|
requirements.txt
CHANGED
|
@@ -1,3 +1,2 @@
|
|
| 1 |
-
|
| 2 |
pandas
|
| 3 |
-
streamlit
|
|
|
|
| 1 |
+
streamlit
|
| 2 |
pandas
|
|
|