Skip to content

Commit

Permalink
Fix remove N/A from table summary
Browse files Browse the repository at this point in the history
  • Loading branch information
victorc365 committed Oct 6, 2023
1 parent b61923f commit 23bf6e4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
12 changes: 6 additions & 6 deletions src/main_generator_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
{
"cell_type": "code",
"execution_count": 13,
"execution_count": 19,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -48,15 +48,15 @@
},
{
"cell_type": "code",
"execution_count": 14,
"execution_count": 20,
"metadata": {
"scrolled": false
},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "3b95936354a245759c69cd0157ff7791",
"model_id": "c669d7f3d67143ba988ff8ea2b9a9034",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -70,7 +70,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "6e14e93ab57c4fb784c6d42cd58bbfc2",
"model_id": "339f144c68394d0d9499b718b09f4faa",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -84,7 +84,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "25c5c668597341fab5b2b99c3580d516",
"model_id": "90a6132e8a5f44b7a71a397cab84267b",
"version_major": 2,
"version_minor": 0
},
Expand All @@ -98,7 +98,7 @@
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "ba12d221cef04e2cbabf48cd81d6ee6a",
"model_id": "1f638ca7da764cb09cac8e40a99c13a6",
"version_major": 2,
"version_minor": 0
},
Expand Down
24 changes: 18 additions & 6 deletions src/synthetic_data_generation/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -1314,18 +1314,30 @@ def create_a_summary_table(df_total_user: pd.DataFrame,
places_count = 0.0
delta_count = 0.0
if not temp_df.empty:
social_situation_count = temp_df[f"{meal}_social_situation"].value_counts(
filter_nan_out = temp_df[~temp_df[f"{meal}_social_situation"].isin([
'N/A'])]
social_situation_count = filter_nan_out[f"{meal}_social_situation"].value_counts(
)
filter_nan_out = temp_df[~temp_df[f"{meal}_place"].isin([
'N/A'])]
places_count = filter_nan_out[f"{meal}_place"].value_counts(
)
places_count = temp_df[f"{meal}_place"].value_counts()
delta_count = {
"mean": temp_df[f"{meal}_delta"].mean(),
"std": temp_df[f"{meal}_delta"].std()
}
temp_list.append(f"""<li><strong>{meal.capitalize()}:</strong>
<p>social situations consume meal: {', '.join([ind+':'+str(social_situation_count[ind]) if ind != "N/A" else "N/A" for ind in social_situation_count.index])}</p>
<p>places consume meal: {', '.join([ind+':'+str(places_count[ind]) if ind != "N/A" else "N/A" for ind in places_count.index])}</p>
<p>appreciation: {delta_count['mean']} &plusmn; {delta_count['std']}</p>
if len(places_count) == 0 and len(social_situation_count) == 0:
temp_list.append(f"""<li><strong>{meal.capitalize()}:</strong>
<p>social situations consume meal: N/A</p>
<p>places consume meal: N/A</p>
<p>appreciation: N/A</p>
</li>""")
else:
temp_list.append(f"""<li><strong>{meal.capitalize()}:</strong>
<p>social situations consume meal: {', '.join([ind+':'+str(social_situation_count[ind]) if ind != "N/A" else "N/A" for ind in social_situation_count.index])}</p>
<p>places consume meal: {', '.join([ind+':'+str(places_count[ind]) if ind != "N/A" else "N/A" for ind in places_count.index])}</p>
<p>appreciation: {delta_count['mean']} &plusmn; {delta_count['std']}</p>
</li>""")
# print(
# f"calculated values condition {condition}: {meal} mean {mean} std {std}")
else:
Expand Down

0 comments on commit 23bf6e4

Please sign in to comment.