Spaces:
Running
Running
James McCool
commited on
Commit
·
76ff10d
1
Parent(s):
220e04f
Refactor data export functionality in app.py by replacing hardcoded column indices with named column mappings for DraftKings and FanDuel, improving code readability and maintainability.
Browse files
app.py
CHANGED
@@ -443,12 +443,14 @@ with tab3:
|
|
443 |
|
444 |
if st.button("Prepare data export", key='data_export'):
|
445 |
data_export = st.session_state.working_seed.copy()
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
|
|
|
|
452 |
st.download_button(
|
453 |
label="Export optimals set",
|
454 |
data=convert_df(data_export),
|
@@ -492,11 +494,13 @@ with tab3:
|
|
492 |
|
493 |
export_file = st.session_state.data_export_display.copy()
|
494 |
if site_var == 'Draftkings':
|
495 |
-
|
496 |
-
|
|
|
497 |
elif site_var == 'Fanduel':
|
498 |
-
|
499 |
-
|
|
|
500 |
|
501 |
with st.container():
|
502 |
if st.button("Reset Optimals", key='reset3'):
|
|
|
443 |
|
444 |
if st.button("Prepare data export", key='data_export'):
|
445 |
data_export = st.session_state.working_seed.copy()
|
446 |
+
if site_var == 'Draftkings':
|
447 |
+
map_columns = ['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']
|
448 |
+
for col_idx in map_columns:
|
449 |
+
data_export[col_idx] = data_export[col_idx].map(dk_id_map)
|
450 |
+
elif site_var == 'Fanduel':
|
451 |
+
map_columns = ['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL']
|
452 |
+
for col_idx in map_columns:
|
453 |
+
data_export[col_idx] = data_export[col_idx].map(fd_id_map)
|
454 |
st.download_button(
|
455 |
label="Export optimals set",
|
456 |
data=convert_df(data_export),
|
|
|
494 |
|
495 |
export_file = st.session_state.data_export_display.copy()
|
496 |
if site_var == 'Draftkings':
|
497 |
+
map_columns = ['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']
|
498 |
+
for col_idx in map_columns:
|
499 |
+
export_file[col_idx] = export_file[col_idx].map(dk_id_map)
|
500 |
elif site_var == 'Fanduel':
|
501 |
+
map_columns = ['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL']
|
502 |
+
for col_idx in map_columns:
|
503 |
+
export_file[col_idx] = export_file[col_idx].map(fd_id_map)
|
504 |
|
505 |
with st.container():
|
506 |
if st.button("Reset Optimals", key='reset3'):
|