Spaces:
Running
Running
James McCool
commited on
Commit
·
efa96d9
1
Parent(s):
7751c90
Refactor app.py to replace session state usage with local variables for site, slate type, and position group selections, improving code clarity and maintaining user input functionality across different views.
Browse files
app.py
CHANGED
@@ -142,11 +142,11 @@ if model_var == 'Scoring Percentages':
|
|
142 |
for key in st.session_state.keys():
|
143 |
del st.session_state[key]
|
144 |
with col2:
|
145 |
-
|
146 |
with col3:
|
147 |
-
|
148 |
with col4:
|
149 |
-
|
150 |
st.title("Scoring Percentages")
|
151 |
if view_var == "Simple":
|
152 |
scoring_percentages = scoring_percentages[['Names', 'Avg Score', '8+ runs', 'Win Percentage']]
|
@@ -168,47 +168,47 @@ if model_var == 'Player ROO':
|
|
168 |
for key in st.session_state.keys():
|
169 |
del st.session_state[key]
|
170 |
with col2:
|
171 |
-
|
172 |
with col3:
|
173 |
-
|
174 |
with col4:
|
175 |
-
|
176 |
with col5:
|
177 |
-
|
178 |
|
179 |
-
if
|
180 |
player_roo_raw = roo_data.copy()
|
181 |
-
if
|
182 |
player_roo_raw['Site'] = 'Draftkings'
|
183 |
|
184 |
-
if
|
185 |
pass
|
186 |
-
elif
|
187 |
player_roo_raw = player_roo_raw[player_roo_raw['Position'] == 'SP']
|
188 |
-
elif
|
189 |
player_roo_raw = player_roo_raw[player_roo_raw['Position'] != 'SP']
|
190 |
-
elif
|
191 |
player_roo_raw['Site'] = 'Fanduel'
|
192 |
|
193 |
-
if
|
194 |
pass
|
195 |
-
elif
|
196 |
player_roo_raw = player_roo_raw[player_roo_raw['Position'] == 'P']
|
197 |
-
elif
|
198 |
player_roo_raw = player_roo_raw[player_roo_raw['Position'] != 'P']
|
199 |
|
200 |
-
if
|
201 |
player_roo_raw = player_roo_raw[player_roo_raw['Slate'] == 'Main']
|
202 |
-
elif
|
203 |
player_roo_raw = player_roo_raw[player_roo_raw['Slate'] == 'Secondary']
|
204 |
-
elif
|
205 |
player_roo_raw = player_roo_raw[player_roo_raw['Slate'] == 'Auxiliary']
|
206 |
|
207 |
-
elif
|
208 |
player_roo_raw = sd_roo_data.copy()
|
209 |
-
if
|
210 |
player_roo_raw['Site'] = 'Draftkings'
|
211 |
-
elif
|
212 |
player_roo_raw['Site'] = 'Fanduel'
|
213 |
st.session_state['player_roo'] = player_roo_raw.drop(columns=['site', 'slate', 'version', 'timestamp'])
|
214 |
if view_var == "Simple":
|
|
|
142 |
for key in st.session_state.keys():
|
143 |
del st.session_state[key]
|
144 |
with col2:
|
145 |
+
site_var1 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'), key='site_var1')
|
146 |
with col3:
|
147 |
+
slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'Secondary Slate', 'All Games'), key='slate_var1')
|
148 |
with col4:
|
149 |
+
own_var1 = st.radio("How would you like to display team ownership?", ('Sum', 'Average'), key='own_var1')
|
150 |
st.title("Scoring Percentages")
|
151 |
if view_var == "Simple":
|
152 |
scoring_percentages = scoring_percentages[['Names', 'Avg Score', '8+ runs', 'Win Percentage']]
|
|
|
168 |
for key in st.session_state.keys():
|
169 |
del st.session_state[key]
|
170 |
with col2:
|
171 |
+
site_var2 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'), key='site_var2')
|
172 |
with col3:
|
173 |
+
slate_type_var2 = st.radio("Which slate type are you loading?", ('Regular', 'Showdown'), key='slate_type_var2')
|
174 |
with col4:
|
175 |
+
slate_var2 = st.radio("Which slate data are you loading?", ('Main', 'Secondary', 'Auxiliary'), key='slate_var2')
|
176 |
with col5:
|
177 |
+
pos_var2 = st.radio("Which position group would you like to view?", ('All', 'Pitchers', 'Hitters'), key='pos_var2')
|
178 |
|
179 |
+
if slate_type_var2 == 'Regular':
|
180 |
player_roo_raw = roo_data.copy()
|
181 |
+
if site_var2 == 'Draftkings':
|
182 |
player_roo_raw['Site'] = 'Draftkings'
|
183 |
|
184 |
+
if pos_var2 == 'All':
|
185 |
pass
|
186 |
+
elif pos_var2 == 'Pitchers':
|
187 |
player_roo_raw = player_roo_raw[player_roo_raw['Position'] == 'SP']
|
188 |
+
elif pos_var2 == 'Hitters':
|
189 |
player_roo_raw = player_roo_raw[player_roo_raw['Position'] != 'SP']
|
190 |
+
elif site_var2 == 'Fanduel':
|
191 |
player_roo_raw['Site'] = 'Fanduel'
|
192 |
|
193 |
+
if pos_var2 == 'All':
|
194 |
pass
|
195 |
+
elif pos_var2 == 'Pitchers':
|
196 |
player_roo_raw = player_roo_raw[player_roo_raw['Position'] == 'P']
|
197 |
+
elif pos_var2 == 'Hitters':
|
198 |
player_roo_raw = player_roo_raw[player_roo_raw['Position'] != 'P']
|
199 |
|
200 |
+
if slate_var2 == 'Main':
|
201 |
player_roo_raw = player_roo_raw[player_roo_raw['Slate'] == 'Main']
|
202 |
+
elif slate_var2 == 'Secondary':
|
203 |
player_roo_raw = player_roo_raw[player_roo_raw['Slate'] == 'Secondary']
|
204 |
+
elif slate_var2 == 'Auxiliary':
|
205 |
player_roo_raw = player_roo_raw[player_roo_raw['Slate'] == 'Auxiliary']
|
206 |
|
207 |
+
elif slate_type_var2 == 'Showdown':
|
208 |
player_roo_raw = sd_roo_data.copy()
|
209 |
+
if site_var2 == 'Draftkings':
|
210 |
player_roo_raw['Site'] = 'Draftkings'
|
211 |
+
elif site_var2 == 'Fanduel':
|
212 |
player_roo_raw['Site'] = 'Fanduel'
|
213 |
st.session_state['player_roo'] = player_roo_raw.drop(columns=['site', 'slate', 'version', 'timestamp'])
|
214 |
if view_var == "Simple":
|