From 393c5276564e0cad5529557f2be2a7fc57e20565 Mon Sep 17 00:00:00 2001 From: Luigi Maiorano Date: Fri, 23 Jan 2026 15:05:35 +0100 Subject: [PATCH] filters --- 02_quant_analysis.py | 33 +++++++++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/02_quant_analysis.py b/02_quant_analysis.py index 434ec36..c1bd7b4 100644 --- a/02_quant_analysis.py +++ b/02_quant_analysis.py @@ -103,9 +103,38 @@ def _(mo): return +@app.cell(hide_code=True) +def _(data_all, mo): + data_all_collected = data_all.collect() + ages = mo.ui.multiselect(options=data_all_collected["QID1"], value=data_all_collected["QID1"].unique(), label="Select Age Group(s):") + income = mo.ui.multiselect(data_all_collected["QID15"], value=data_all_collected["QID15"], label="Select Income Group(s):") + gender = mo.ui.multiselect(data_all_collected["QID2"], value=data_all_collected["QID2"], label="Select Gender(s)") + ethnicity = mo.ui.multiselect(data_all_collected["QID3"], value=data_all_collected["QID3"], label="Select Ethnicities:") + consumer = mo.ui.multiselect(data_all_collected["Consumer"], value=data_all_collected["Consumer"], label="Select Consumer Groups:") + + + mo.md(f""" + # Data Filters + + + {ages} + + {gender} + + {ethnicity} + + {income} + + {consumer} + + """) + return ages, consumer, ethnicity, gender, income + + @app.cell -def _(data_all, survey): - data = survey.filter_data(data_all, age=None, gender=None, income=None, ethnicity=None, consumer=None) +def _(ages, consumer, data_all, ethnicity, gender, income, survey): + data = survey.filter_data(data_all, age=ages.value, gender=gender.value, income=income.value, ethnicity=ethnicity.value, consumer=consumer.value) + data.collect() return (data,)