Spaces:
Sleeping
Sleeping
Commit
·
db46464
1
Parent(s):
8ff835f
Update app.py
Browse files
app.py
CHANGED
@@ -64,10 +64,19 @@ with st.expander("Search and filter recipes"):
|
|
64 |
|
65 |
with st.expander("Home bar"):
|
66 |
# input home bar
|
67 |
-
bar_dict = [{"ingredient":"
|
68 |
bar_df = pd.DataFrame(bar_dict)
|
69 |
-
st.data_editor(bar_df)
|
70 |
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
st.dataframe(recipes[recipes['name'].isin(filter_all)], hide_index=True)
|
|
|
64 |
|
65 |
with st.expander("Home bar"):
|
66 |
# input home bar
|
67 |
+
bar_dict = [{"ingredient":"rye", "have": False}, {"ingredient":"simple syrup", "have": False}, {"ingredient":"angostura bitters", "have": False}]
|
68 |
bar_df = pd.DataFrame(bar_dict)
|
69 |
+
st.data_editor(bar_df, hide_index=True)
|
70 |
|
71 |
+
ingredients_joined = ingredients.join(bar_df.set_index('ingredients'), on='ingredients')
|
72 |
+
ingredients_joined.replace({'have': {True: 1, False: 0}}, inplace=True)
|
73 |
+
pivot = ingredients_joined.groupby('name').agg(sum_needs_ingredients=('have', 'count'), sum_has_ingredients=('have', 'sum')).reset_index()
|
74 |
+
filter_1 = (pivot['sum_has_ingredients'] > 0) & (pivot['sum_needs_ingredients'] > 0)
|
75 |
+
filter_2 = pivot['sum_needs_ingredients'] == pivot['sum_has_ingredients']
|
76 |
+
filter_all = filter_1 & filter_2
|
77 |
+
filter_bar = pivot.loc[filter_all, 'name'].to_list()
|
78 |
+
|
79 |
+
|
80 |
+
st.header("Recipes")
|
81 |
+
filter_all = list(set(filter_name) & set(filter_ingredient) & set(filter_source) & set(filter_type) & set(filter_bar))
|
82 |
st.dataframe(recipes[recipes['name'].isin(filter_all)], hide_index=True)
|