James McCool commited on
Commit
dcc4ea4
·
1 Parent(s): 8d20291

Refactor Load/Reset Data button functionality in app.py to clear session state and initialize lineups for both Draftkings and Fanduel, improving data management and user experience across multiple tabs.

Browse files
Files changed (1) hide show
  1. app.py +17 -9
app.py CHANGED
@@ -129,16 +129,20 @@ with tab1:
129
  with st.expander("Info and Filters"):
130
  col1, col2, col3, col4 = st.columns([3, 3, 3, 3])
131
  with col1:
132
- if st.button("Load/Reset Data", key='reset1'):
133
- st.cache_data.clear()
134
- roo_data, sd_roo_data, scoring_percentages = init_baselines()
135
- hold_display = roo_data
 
 
 
 
136
  with col2:
137
- site_var1 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'), key='site_var1')
138
  with col3:
139
- slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'Secondary Slate', 'All Games'), key='slate_var1')
140
  with col4:
141
- own_var1 = st.radio("How would you like to display team ownership?", ('Sum', 'Average'), key='own_var1')
142
  st.title("Scoring Percentages")
143
  if view_var == "Simple":
144
  scoring_percentages = scoring_percentages[['Names', 'Avg Score', '8+ runs', 'Win Percentage']]
@@ -151,10 +155,14 @@ with tab2:
151
  with st.expander("Info and Filters"):
152
  col1, col2, col3, col4, col5 = st.columns([3, 3, 3, 3, 3])
153
  with col1:
154
- if st.button("Load/Reset Data", key='reset1'):
155
  st.cache_data.clear()
156
  roo_data, sd_roo_data, scoring_percentages = init_baselines()
157
  hold_display = roo_data
 
 
 
 
158
  with col2:
159
  site_var2 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'), key='site_var2')
160
  with col3:
@@ -177,7 +185,7 @@ with tab2:
177
 
178
  with tab3:
179
  with st.expander("Info and Filters"):
180
- if st.button("Load/Reset Data", key='reset2'):
181
  st.cache_data.clear()
182
  roo_data, sd_roo_data, scoring_percentages = init_baselines()
183
  hold_display = roo_data
 
129
  with st.expander("Info and Filters"):
130
  col1, col2, col3, col4 = st.columns([3, 3, 3, 3])
131
  with col1:
132
+ if st.button("Load/Reset Data", key='reset1'):
133
+ st.cache_data.clear()
134
+ roo_data, sd_roo_data, scoring_percentages = init_baselines()
135
+ hold_display = roo_data
136
+ dk_lineups = init_DK_lineups('Main')
137
+ fd_lineups = init_FD_lineups('Main')
138
+ for key in st.session_state.keys():
139
+ del st.session_state[key]
140
  with col2:
141
+ site_var1 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'), key='site_var1')
142
  with col3:
143
+ slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'Secondary Slate', 'All Games'), key='slate_var1')
144
  with col4:
145
+ own_var1 = st.radio("How would you like to display team ownership?", ('Sum', 'Average'), key='own_var1')
146
  st.title("Scoring Percentages")
147
  if view_var == "Simple":
148
  scoring_percentages = scoring_percentages[['Names', 'Avg Score', '8+ runs', 'Win Percentage']]
 
155
  with st.expander("Info and Filters"):
156
  col1, col2, col3, col4, col5 = st.columns([3, 3, 3, 3, 3])
157
  with col1:
158
+ if st.button("Load/Reset Data", key='reset2'):
159
  st.cache_data.clear()
160
  roo_data, sd_roo_data, scoring_percentages = init_baselines()
161
  hold_display = roo_data
162
+ dk_lineups = init_DK_lineups('Main')
163
+ fd_lineups = init_FD_lineups('Main')
164
+ for key in st.session_state.keys():
165
+ del st.session_state[key]
166
  with col2:
167
  site_var2 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'), key='site_var2')
168
  with col3:
 
185
 
186
  with tab3:
187
  with st.expander("Info and Filters"):
188
+ if st.button("Load/Reset Data", key='reset3'):
189
  st.cache_data.clear()
190
  roo_data, sd_roo_data, scoring_percentages = init_baselines()
191
  hold_display = roo_data