Spaces:
Running
Running
James McCool
commited on
Commit
·
d617731
1
Parent(s):
7e8dfc1
added functionality for id exporting with the optimals
Browse files
app.py
CHANGED
@@ -104,7 +104,7 @@ def load_overall_stats():
|
|
104 |
|
105 |
raw_display = pd.DataFrame(list(cursor))
|
106 |
raw_display = raw_display[['Player', 'Minutes Proj', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '4x%', '5x%', '6x%', 'GPP%',
|
107 |
-
'Own', 'Small_Own', 'Large_Own', 'Cash_Own', 'CPT_Own', 'LevX', 'ValX', 'site', 'version', 'slate', 'timestamp']]
|
108 |
raw_display = raw_display.loc[raw_display['Median'] > 0]
|
109 |
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
|
110 |
roo_raw = raw_display.sort_values(by='Median', ascending=False)
|
@@ -155,6 +155,7 @@ def convert_df(array):
|
|
155 |
return array.to_csv().encode('utf-8')
|
156 |
|
157 |
dk_raw, fd_raw, dk_raw_sec, fd_raw_sec, roo_raw, timestamp, roo_backlog = load_overall_stats()
|
|
|
158 |
try:
|
159 |
dk_lineups = init_DK_lineups()
|
160 |
fd_lineups = init_FD_lineups()
|
@@ -269,6 +270,7 @@ with tab1:
|
|
269 |
if st.button("Load/Reset Data", key='reset1'):
|
270 |
st.cache_data.clear()
|
271 |
dk_raw, fd_raw, dk_raw_sec, fd_raw_sec, roo_raw, timestamp, roo_backlog = load_overall_stats()
|
|
|
272 |
dk_lineups = init_DK_lineups()
|
273 |
fd_lineups = init_FD_lineups()
|
274 |
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
@@ -315,6 +317,8 @@ with tab1:
|
|
315 |
elif view_var2 == 'Simple':
|
316 |
display_proj = display_proj[['Player', 'Team', 'Position', 'Median', 'GPP%', 'ValX']]
|
317 |
export_data = display_proj.copy()
|
|
|
|
|
318 |
display_proj = display_proj.set_index('Player')
|
319 |
st.session_state.display_proj = display_proj
|
320 |
|
@@ -355,6 +359,7 @@ with tab2:
|
|
355 |
|
356 |
if site_var1 == 'Draftkings':
|
357 |
raw_baselines = dk_raw
|
|
|
358 |
# Get the minimum and maximum ownership values from dk_lineups
|
359 |
min_own = np.min(dk_lineups[:,14])
|
360 |
max_own = np.max(dk_lineups[:,14])
|
@@ -368,6 +373,7 @@ with tab2:
|
|
368 |
|
369 |
elif site_var1 == 'Fanduel':
|
370 |
raw_baselines = fd_raw
|
|
|
371 |
min_own = np.min(fd_lineups[:,15])
|
372 |
max_own = np.max(fd_lineups[:,15])
|
373 |
column_names = fd_columns
|
@@ -380,6 +386,12 @@ with tab2:
|
|
380 |
|
381 |
if st.button("Prepare data export", key='data_export'):
|
382 |
data_export = st.session_state.working_seed.copy()
|
|
|
|
|
|
|
|
|
|
|
|
|
383 |
st.download_button(
|
384 |
label="Export optimals set",
|
385 |
data=convert_df(data_export),
|
|
|
104 |
|
105 |
raw_display = pd.DataFrame(list(cursor))
|
106 |
raw_display = raw_display[['Player', 'Minutes Proj', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '4x%', '5x%', '6x%', 'GPP%',
|
107 |
+
'Own', 'Small_Own', 'Large_Own', 'Cash_Own', 'CPT_Own', 'LevX', 'ValX', 'site', 'version', 'slate', 'timestamp', 'player_ID']]
|
108 |
raw_display = raw_display.loc[raw_display['Median'] > 0]
|
109 |
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
|
110 |
roo_raw = raw_display.sort_values(by='Median', ascending=False)
|
|
|
155 |
return array.to_csv().encode('utf-8')
|
156 |
|
157 |
dk_raw, fd_raw, dk_raw_sec, fd_raw_sec, roo_raw, timestamp, roo_backlog = load_overall_stats()
|
158 |
+
|
159 |
try:
|
160 |
dk_lineups = init_DK_lineups()
|
161 |
fd_lineups = init_FD_lineups()
|
|
|
270 |
if st.button("Load/Reset Data", key='reset1'):
|
271 |
st.cache_data.clear()
|
272 |
dk_raw, fd_raw, dk_raw_sec, fd_raw_sec, roo_raw, timestamp, roo_backlog = load_overall_stats()
|
273 |
+
id_dict = dict(zip(roo_raw.Player, roo_raw.player_ID))
|
274 |
dk_lineups = init_DK_lineups()
|
275 |
fd_lineups = init_FD_lineups()
|
276 |
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
|
|
317 |
elif view_var2 == 'Simple':
|
318 |
display_proj = display_proj[['Player', 'Team', 'Position', 'Median', 'GPP%', 'ValX']]
|
319 |
export_data = display_proj.copy()
|
320 |
+
|
321 |
+
|
322 |
display_proj = display_proj.set_index('Player')
|
323 |
st.session_state.display_proj = display_proj
|
324 |
|
|
|
359 |
|
360 |
if site_var1 == 'Draftkings':
|
361 |
raw_baselines = dk_raw
|
362 |
+
id_dict = dict(zip(raw_baselines.Player, raw_baselines.player_ID))
|
363 |
# Get the minimum and maximum ownership values from dk_lineups
|
364 |
min_own = np.min(dk_lineups[:,14])
|
365 |
max_own = np.max(dk_lineups[:,14])
|
|
|
373 |
|
374 |
elif site_var1 == 'Fanduel':
|
375 |
raw_baselines = fd_raw
|
376 |
+
id_dict = dict(zip(raw_baselines.Player, raw_baselines.player_ID))
|
377 |
min_own = np.min(fd_lineups[:,15])
|
378 |
max_own = np.max(fd_lineups[:,15])
|
379 |
column_names = fd_columns
|
|
|
386 |
|
387 |
if st.button("Prepare data export", key='data_export'):
|
388 |
data_export = st.session_state.working_seed.copy()
|
389 |
+
if site_var1 == 'Draftkings':
|
390 |
+
for col in data_export.iloc[:, 0:8].columns:
|
391 |
+
data_export[col] = data_export[col].map(id_dict)
|
392 |
+
elif site_var1 == 'Fanduel':
|
393 |
+
for col in data_export.iloc[:, 0:9].columns:
|
394 |
+
data_export[col] = data_export[col].map(id_dict)
|
395 |
st.download_button(
|
396 |
label="Export optimals set",
|
397 |
data=convert_df(data_export),
|