Spaces:
Sleeping
Sleeping
Commit
·
db82ba3
1
Parent(s):
46d4747
Update app.py
Browse files
app.py
CHANGED
@@ -19,6 +19,10 @@ def get_bar_data():
|
|
19 |
if 'filter_bar' not in st.session_state:
|
20 |
st.session_state.filter_bar = recipes['name'].to_list()
|
21 |
|
|
|
|
|
|
|
|
|
22 |
with st.expander("Search and filter recipes"):
|
23 |
# name search
|
24 |
name_search = st.text_input('Search recipes by name')
|
@@ -70,7 +74,7 @@ with st.expander("Search and filter recipes"):
|
|
70 |
filter_type = recipes.loc[filter_1, 'name'].to_list()
|
71 |
|
72 |
def submit_bar():
|
73 |
-
ingredients_joined = ingredients.join(bar_df_edited.set_index('ingredients'), on='ingredients')
|
74 |
ingredients_joined.replace({'have': {True: 1, False: 0}}, inplace=True)
|
75 |
if bar_df_edited['have'].sum() == 0:
|
76 |
st.session_state.filter_bar = recipes['name'].to_list()
|
@@ -83,12 +87,12 @@ def submit_bar():
|
|
83 |
|
84 |
def reset_bar():
|
85 |
st.session_state.filter_bar = recipes['name'].to_list()
|
86 |
-
bar_df_edited = get_bar_data()
|
87 |
|
88 |
with st.expander("Home bar"):
|
89 |
bar_df = get_bar_data()
|
90 |
# input home bar
|
91 |
-
bar_df_edited = st.data_editor(bar_df, disabled=["ingredients"], hide_index=True)
|
92 |
st.button(label='Submit Bar', on_click=submit_bar)
|
93 |
st.button(label='Reset', on_click=reset_bar)
|
94 |
|
|
|
19 |
if 'filter_bar' not in st.session_state:
|
20 |
st.session_state.filter_bar = recipes['name'].to_list()
|
21 |
|
22 |
+
if 'bar_df' not in st.session_state:
|
23 |
+
st.session_state.bar_df = get_bar_data()
|
24 |
+
st.session_state.bar_df_edited = st.session_state.bar_df.copy()
|
25 |
+
|
26 |
with st.expander("Search and filter recipes"):
|
27 |
# name search
|
28 |
name_search = st.text_input('Search recipes by name')
|
|
|
74 |
filter_type = recipes.loc[filter_1, 'name'].to_list()
|
75 |
|
76 |
def submit_bar():
|
77 |
+
ingredients_joined = ingredients.join(st.session_state.bar_df_edited.set_index('ingredients'), on='ingredients')
|
78 |
ingredients_joined.replace({'have': {True: 1, False: 0}}, inplace=True)
|
79 |
if bar_df_edited['have'].sum() == 0:
|
80 |
st.session_state.filter_bar = recipes['name'].to_list()
|
|
|
87 |
|
88 |
def reset_bar():
|
89 |
st.session_state.filter_bar = recipes['name'].to_list()
|
90 |
+
st.session_state.bar_df_edited = get_bar_data()
|
91 |
|
92 |
with st.expander("Home bar"):
|
93 |
bar_df = get_bar_data()
|
94 |
# input home bar
|
95 |
+
st.session_state.bar_df_edited = st.data_editor(st.session_state.bar_df, disabled=["ingredients"], hide_index=True)
|
96 |
st.button(label='Submit Bar', on_click=submit_bar)
|
97 |
st.button(label='Reset', on_click=reset_bar)
|
98 |
|