demographics section done
This commit is contained in:
@@ -22,7 +22,6 @@ def _():
|
||||
initial_path="./data/exports", multiple=False, restrict_navigation=True, filetypes=[".csv"], label="Select 'Labels' File"
|
||||
)
|
||||
file_browser
|
||||
|
||||
return (file_browser,)
|
||||
|
||||
|
||||
@@ -117,7 +116,7 @@ def _(data_validated):
|
||||
data = data_validated
|
||||
|
||||
data.collect()
|
||||
return
|
||||
return (data,)
|
||||
|
||||
|
||||
@app.cell(hide_code=True)
|
||||
@@ -130,6 +129,81 @@ def _():
|
||||
return
|
||||
|
||||
|
||||
@app.cell
|
||||
def _(S, data):
|
||||
demographics = S.get_demographics(data)[0].collect()
|
||||
demographics
|
||||
return (demographics,)
|
||||
|
||||
|
||||
@app.cell(hide_code=True)
|
||||
def _():
|
||||
mo.md(r"""
|
||||
## Lucia confirmation missing 'Consumer' data
|
||||
""")
|
||||
return
|
||||
|
||||
|
||||
@app.cell
|
||||
def _(demographics):
|
||||
# Demographics where 'Consumer' is null
|
||||
demographics_no_consumer = demographics.filter(pl.col('Consumer').is_null())['_recordId'].to_list()
|
||||
# demographics_no_consumer
|
||||
return (demographics_no_consumer,)
|
||||
|
||||
|
||||
@app.cell
|
||||
def _(data_all, demographics_no_consumer):
|
||||
# check if the responses with missing 'Consumer type' in demographics are all business owners as Lucia mentioned
|
||||
assert all(data_all.filter(pl.col('_recordId').is_in(demographics_no_consumer)).collect()['QID4'] == 'Yes'), "Not all respondents with missing 'Consumer' are business owners."
|
||||
return
|
||||
|
||||
|
||||
@app.cell
|
||||
def _(data_all):
|
||||
# Check if all business owners are missing a 'Consumer type' in demographics
|
||||
assert all([a is None for a in data_all.filter(pl.col('QID4') == 'Yes').collect()['Consumer'].unique()]) , "Not all business owners are missing 'Consumer type' in demographics."
|
||||
return
|
||||
|
||||
|
||||
@app.cell(hide_code=True)
|
||||
def _():
|
||||
mo.md(r"""
|
||||
## Demographic Distributions
|
||||
""")
|
||||
return
|
||||
|
||||
|
||||
@app.cell
|
||||
def _():
|
||||
demo_plot_cols = [
|
||||
'Age',
|
||||
'Gender',
|
||||
# 'Race/Ethnicity',
|
||||
'Bussiness_Owner',
|
||||
'Consumer'
|
||||
]
|
||||
return (demo_plot_cols,)
|
||||
|
||||
|
||||
@app.cell
|
||||
def _(S, demo_plot_cols, demographics):
|
||||
_content = """
|
||||
## Demographic Distributions
|
||||
|
||||
"""
|
||||
for c in demo_plot_cols:
|
||||
_fig = S.plot_demographic_distribution(
|
||||
data=demographics,
|
||||
column=c,
|
||||
title=f"{c.replace('Bussiness', 'Business').replace('_', ' ')} Distribution of Survey Respondents"
|
||||
)
|
||||
_content += f"""{mo.ui.altair_chart(_fig)}\n\n"""
|
||||
|
||||
mo.md(_content)
|
||||
return
|
||||
|
||||
|
||||
@app.cell(hide_code=True)
|
||||
def _():
|
||||
mo.md(r"""
|
||||
|
||||
Reference in New Issue
Block a user