adrianpierce commited on
Commit
46d4747
·
1 Parent(s): 5e99366

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -12,6 +12,10 @@ recipes_json = json.load(f)
12
  recipes = pd.DataFrame(recipes_json)
13
  ingredients = pd.DataFrame(recipes_json).explode('ingredients')
14
 
 
 
 
 
15
  if 'filter_bar' not in st.session_state:
16
  st.session_state.filter_bar = recipes['name'].to_list()
17
 
@@ -79,12 +83,11 @@ def submit_bar():
79
 
80
  def reset_bar():
81
  st.session_state.filter_bar = recipes['name'].to_list()
 
82
 
83
  with st.expander("Home bar"):
84
-
85
  # input home bar
86
- bar_dict = [{"ingredients":"rye", "have": False}, {"ingredients":"cognac", "have": False}]
87
- bar_df = pd.DataFrame(bar_dict)
88
  bar_df_edited = st.data_editor(bar_df, disabled=["ingredients"], hide_index=True)
89
  st.button(label='Submit Bar', on_click=submit_bar)
90
  st.button(label='Reset', on_click=reset_bar)
 
12
  recipes = pd.DataFrame(recipes_json)
13
  ingredients = pd.DataFrame(recipes_json).explode('ingredients')
14
 
15
+ def get_bar_data():
16
+ bar_dict = [{"ingredients":"rye", "have": False}, {"ingredients":"cognac", "have": False}]
17
+ return pd.DataFrame(bar_dict)
18
+
19
  if 'filter_bar' not in st.session_state:
20
  st.session_state.filter_bar = recipes['name'].to_list()
21
 
 
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)