Spaces:
Running
Running
James McCool
commited on
Commit
·
220e04f
1
Parent(s):
df80a5c
Add player ID mappings for DraftKings and FanDuel in app.py to enhance data export functionality, ensuring accurate player identification in exported files.
Browse files
app.py
CHANGED
@@ -70,7 +70,9 @@ def init_baselines():
|
|
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()
|
@@ -103,7 +105,7 @@ def init_baselines():
|
|
103 |
scoring_percentages['DK LevX'] = scoring_percentages['Top Score'].rank(pct=True).astype(float) - scoring_percentages['DK Own%'].rank(pct=True).astype(float)
|
104 |
scoring_percentages['FD LevX'] = scoring_percentages['Top Score'].rank(pct=True).astype(float) - scoring_percentages['FD Own%'].rank(pct=True).astype(float)
|
105 |
|
106 |
-
return roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo
|
107 |
|
108 |
@st.cache_data(ttl = 60)
|
109 |
def init_DK_lineups(type_var, slate_var):
|
@@ -259,7 +261,7 @@ col1, col2 = st.columns([1, 9])
|
|
259 |
with col1:
|
260 |
if st.button("Load/Reset Data", key='reset'):
|
261 |
st.cache_data.clear()
|
262 |
-
roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo = init_baselines()
|
263 |
hold_display = roo_data
|
264 |
dk_lineups = init_DK_lineups('Regular', 'Main')
|
265 |
fd_lineups = init_FD_lineups('Regular', 'Main')
|
@@ -276,7 +278,7 @@ with col2:
|
|
276 |
|
277 |
tab1, tab2, tab3 = st.tabs(["Scoring Percentages", "Player ROO", "Optimals"])
|
278 |
|
279 |
-
roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo = init_baselines()
|
280 |
hold_display = roo_data
|
281 |
|
282 |
with tab1:
|
@@ -489,12 +491,12 @@ with tab3:
|
|
489 |
st.session_state.data_export_display = pd.DataFrame(st.session_state.working_seed[0:lineup_num_var], columns=column_names)
|
490 |
|
491 |
export_file = st.session_state.data_export_display.copy()
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
|
499 |
with st.container():
|
500 |
if st.button("Reset Optimals", key='reset3'):
|
|
|
70 |
roo_data['Salary'] = roo_data['Salary'].astype(int)
|
71 |
|
72 |
dk_roo = roo_data[roo_data['Site'] == 'Draftkings']
|
73 |
+
dk_id_map = dict(zip(dk_roo['player_ID'], dk_roo['Player']))
|
74 |
fd_roo = roo_data[roo_data['Site'] == 'Fanduel']
|
75 |
+
fd_id_map = dict(zip(fd_roo['player_ID'], fd_roo['Player']))
|
76 |
|
77 |
collection = db["Player_SD_Range_Of_Outcomes"]
|
78 |
cursor = collection.find()
|
|
|
105 |
scoring_percentages['DK LevX'] = scoring_percentages['Top Score'].rank(pct=True).astype(float) - scoring_percentages['DK Own%'].rank(pct=True).astype(float)
|
106 |
scoring_percentages['FD LevX'] = scoring_percentages['Top Score'].rank(pct=True).astype(float) - scoring_percentages['FD Own%'].rank(pct=True).astype(float)
|
107 |
|
108 |
+
return roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo, dk_id_map, fd_id_map
|
109 |
|
110 |
@st.cache_data(ttl = 60)
|
111 |
def init_DK_lineups(type_var, slate_var):
|
|
|
261 |
with col1:
|
262 |
if st.button("Load/Reset Data", key='reset'):
|
263 |
st.cache_data.clear()
|
264 |
+
roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo, dk_id_map, fd_id_map = init_baselines()
|
265 |
hold_display = roo_data
|
266 |
dk_lineups = init_DK_lineups('Regular', 'Main')
|
267 |
fd_lineups = init_FD_lineups('Regular', 'Main')
|
|
|
278 |
|
279 |
tab1, tab2, tab3 = st.tabs(["Scoring Percentages", "Player ROO", "Optimals"])
|
280 |
|
281 |
+
roo_data, sd_roo_data, scoring_percentages, dk_roo, fd_roo, dk_id_map, fd_id_map = init_baselines()
|
282 |
hold_display = roo_data
|
283 |
|
284 |
with tab1:
|
|
|
491 |
st.session_state.data_export_display = pd.DataFrame(st.session_state.working_seed[0:lineup_num_var], columns=column_names)
|
492 |
|
493 |
export_file = st.session_state.data_export_display.copy()
|
494 |
+
if site_var == 'Draftkings':
|
495 |
+
for col_idx in range(10):
|
496 |
+
export_file.iloc[:, col_idx] = export_file.iloc[:, col_idx].map(dk_id_map)
|
497 |
+
elif site_var == 'Fanduel':
|
498 |
+
for col_idx in range(9):
|
499 |
+
export_file.iloc[:, col_idx] = export_file.iloc[:, col_idx].map(fd_id_map)
|
500 |
|
501 |
with st.container():
|
502 |
if st.button("Reset Optimals", key='reset3'):
|