Spaces:
Running
Running
James McCool
commited on
Commit
·
1e1b470
1
Parent(s):
64fdc53
Enhance player ROO data handling in app.py by introducing separate dataframes for DraftKings and FanDuel, improving clarity and organization in the data processing flow while maintaining existing functionality.
Browse files
app.py
CHANGED
@@ -68,6 +68,9 @@ def init_baselines():
|
|
68 |
|
69 |
roo_data = player_frame.drop(columns=['_id'])
|
70 |
roo_data['Salary'] = roo_data['Salary'].astype(int)
|
|
|
|
|
|
|
71 |
|
72 |
collection = db["Player_SD_Range_Of_Outcomes"]
|
73 |
cursor = collection.find()
|
@@ -85,7 +88,7 @@ def init_baselines():
|
|
85 |
scoring_percentages['8+ runs'] = scoring_percentages['8+ runs'].replace('%', '', regex=True).astype(float) / 100
|
86 |
scoring_percentages['Win Percentage'] = scoring_percentages['Win Percentage'].replace('%', '', regex=True).astype(float) / 100
|
87 |
|
88 |
-
return roo_data, sd_roo_data, scoring_percentages
|
89 |
|
90 |
@st.cache_data(ttl = 60)
|
91 |
def init_DK_lineups(type_var, slate_var):
|
@@ -241,7 +244,7 @@ col1, col2 = st.columns([1, 9])
|
|
241 |
with col1:
|
242 |
if st.button("Load/Reset Data", key='reset'):
|
243 |
st.cache_data.clear()
|
244 |
-
roo_data, sd_roo_data, scoring_percentages = init_baselines()
|
245 |
hold_display = roo_data
|
246 |
dk_lineups = init_DK_lineups('Regular', 'Main')
|
247 |
fd_lineups = init_FD_lineups('Regular', 'Main')
|
@@ -258,7 +261,7 @@ with col2:
|
|
258 |
|
259 |
tab1, tab2, tab3 = st.tabs(["Scoring Percentages", "Player ROO", "Optimals"])
|
260 |
|
261 |
-
roo_data, sd_roo_data, scoring_percentages = init_baselines()
|
262 |
hold_display = roo_data
|
263 |
|
264 |
with tab1:
|
@@ -286,25 +289,27 @@ with tab2:
|
|
286 |
else:
|
287 |
team_select2 = None
|
288 |
if slate_type_var2 == 'Regular':
|
289 |
-
player_roo_raw = roo_data.copy()
|
290 |
if site_var == 'Draftkings':
|
291 |
-
|
|
|
292 |
|
293 |
if pos_var2 == 'All':
|
294 |
pass
|
295 |
elif pos_var2 == 'Pitchers':
|
296 |
-
player_roo_raw = player_roo_raw[player_roo_raw['Position']
|
297 |
elif pos_var2 == 'Hitters':
|
298 |
-
player_roo_raw = player_roo_raw[player_roo_raw['Position']
|
|
|
299 |
elif site_var == 'Fanduel':
|
300 |
-
|
|
|
301 |
|
302 |
if pos_var2 == 'All':
|
303 |
pass
|
304 |
elif pos_var2 == 'Pitchers':
|
305 |
-
player_roo_raw = player_roo_raw[player_roo_raw['Position']
|
306 |
elif pos_var2 == 'Hitters':
|
307 |
-
player_roo_raw = player_roo_raw[player_roo_raw['Position']
|
308 |
|
309 |
if slate_var2 == 'Main':
|
310 |
player_roo_raw = player_roo_raw[player_roo_raw['Slate'] == 'main_slate']
|
|
|
68 |
|
69 |
roo_data = player_frame.drop(columns=['_id'])
|
70 |
roo_data['Salary'] = roo_data['Salary'].astype(int)
|
71 |
+
|
72 |
+
dk_roo = roo_data[roo_data['Site'] == 'Draftkings']
|
73 |
+
fd_roo = roo_data[roo_data['Site'] == 'Fanduel']
|
74 |
|
75 |
collection = db["Player_SD_Range_Of_Outcomes"]
|
76 |
cursor = collection.find()
|
|
|
88 |
scoring_percentages['8+ runs'] = scoring_percentages['8+ runs'].replace('%', '', regex=True).astype(float) / 100
|
89 |
scoring_percentages['Win Percentage'] = scoring_percentages['Win Percentage'].replace('%', '', regex=True).astype(float) / 100
|
90 |
|
91 |
+
return roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo
|
92 |
|
93 |
@st.cache_data(ttl = 60)
|
94 |
def init_DK_lineups(type_var, slate_var):
|
|
|
244 |
with col1:
|
245 |
if st.button("Load/Reset Data", key='reset'):
|
246 |
st.cache_data.clear()
|
247 |
+
roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo = init_baselines()
|
248 |
hold_display = roo_data
|
249 |
dk_lineups = init_DK_lineups('Regular', 'Main')
|
250 |
fd_lineups = init_FD_lineups('Regular', 'Main')
|
|
|
261 |
|
262 |
tab1, tab2, tab3 = st.tabs(["Scoring Percentages", "Player ROO", "Optimals"])
|
263 |
|
264 |
+
roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo = init_baselines()
|
265 |
hold_display = roo_data
|
266 |
|
267 |
with tab1:
|
|
|
289 |
else:
|
290 |
team_select2 = None
|
291 |
if slate_type_var2 == 'Regular':
|
|
|
292 |
if site_var == 'Draftkings':
|
293 |
+
|
294 |
+
player_roo_raw = dk_roo.copy()
|
295 |
|
296 |
if pos_var2 == 'All':
|
297 |
pass
|
298 |
elif pos_var2 == 'Pitchers':
|
299 |
+
player_roo_raw = player_roo_raw[player_roo_raw['Position'].str.contains('P')]
|
300 |
elif pos_var2 == 'Hitters':
|
301 |
+
player_roo_raw = player_roo_raw[player_roo_raw['Position'].str.contains('P')]
|
302 |
+
|
303 |
elif site_var == 'Fanduel':
|
304 |
+
|
305 |
+
player_roo_raw = fd_roo.copy()
|
306 |
|
307 |
if pos_var2 == 'All':
|
308 |
pass
|
309 |
elif pos_var2 == 'Pitchers':
|
310 |
+
player_roo_raw = player_roo_raw[player_roo_raw['Position'].str.contains('P')]
|
311 |
elif pos_var2 == 'Hitters':
|
312 |
+
player_roo_raw = player_roo_raw[player_roo_raw['Position'].str.contains('P')]
|
313 |
|
314 |
if slate_var2 == 'Main':
|
315 |
player_roo_raw = player_roo_raw[player_roo_raw['Slate'] == 'main_slate']
|