Spaces:
Running
Running
James McCool
commited on
Commit
·
e48ec28
1
Parent(s):
0ad72bc
Enhance app.py with new download functionality: add export options for both Regular and Portfolio Manager views, allowing users to download player data in CSV format, improving data accessibility and user experience.
Browse files
app.py
CHANGED
@@ -464,9 +464,27 @@ with tab1:
|
|
464 |
elif view_var2 == 'Simple':
|
465 |
display_proj = display_proj[['Player', 'Position', 'Salary', 'Median', 'GPP%', 'Own']]
|
466 |
export_data = display_proj.copy()
|
|
|
|
|
467 |
|
468 |
# display_proj = display_proj.set_index('Player')
|
469 |
st.session_state.display_proj = display_proj.set_index('Player', drop=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
470 |
|
471 |
with display_container_1:
|
472 |
display_container = st.empty()
|
@@ -478,15 +496,7 @@ with tab1:
|
|
478 |
st.dataframe(st.session_state.display_proj.style.set_properties(**{'font-size': '6pt'}).background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(roo_format, precision=2),
|
479 |
height=1000, use_container_width = True)
|
480 |
|
481 |
-
|
482 |
-
display_dl_container = st.empty()
|
483 |
-
if 'display_proj' in st.session_state:
|
484 |
-
st.download_button(
|
485 |
-
label="Export Tables",
|
486 |
-
data=convert_df_to_csv(export_data),
|
487 |
-
file_name='NBA_ROO_export.csv',
|
488 |
-
mime='text/csv',
|
489 |
-
)
|
490 |
|
491 |
with tab2:
|
492 |
with st.expander("Info and Filters"):
|
|
|
464 |
elif view_var2 == 'Simple':
|
465 |
display_proj = display_proj[['Player', 'Position', 'Salary', 'Median', 'GPP%', 'Own']]
|
466 |
export_data = display_proj.copy()
|
467 |
+
export_data_pm = display_proj[['Player', 'Position', 'Team', 'Salary', 'Median', 'Own%', 'CPT_Own']]
|
468 |
+
export_data_pm = export_data_pm.rename(columns={'Own%': 'ownership', 'Median': 'median', 'Player': 'player_names', 'Position': 'position', 'Team': 'team', 'Salary': 'salary', 'CPT_Own': 'captain ownership'})
|
469 |
|
470 |
# display_proj = display_proj.set_index('Player')
|
471 |
st.session_state.display_proj = display_proj.set_index('Player', drop=True)
|
472 |
+
|
473 |
+
reg_dl_col, pm_dl_col, blank_col = st.columns([2, 2, 6])
|
474 |
+
with reg_dl_col:
|
475 |
+
st.download_button(
|
476 |
+
label="Export ROO (Regular)",
|
477 |
+
data=convert_df_to_csv(export_data),
|
478 |
+
file_name='NBA_ROO_export.csv',
|
479 |
+
mime='text/csv',
|
480 |
+
)
|
481 |
+
with pm_dl_col:
|
482 |
+
st.download_button(
|
483 |
+
label="Export ROO (Portfolio Manager)",
|
484 |
+
data=convert_df_to_csv(export_data_pm),
|
485 |
+
file_name='NBA_ROO_export.csv',
|
486 |
+
mime='text/csv',
|
487 |
+
)
|
488 |
|
489 |
with display_container_1:
|
490 |
display_container = st.empty()
|
|
|
496 |
st.dataframe(st.session_state.display_proj.style.set_properties(**{'font-size': '6pt'}).background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(roo_format, precision=2),
|
497 |
height=1000, use_container_width = True)
|
498 |
|
499 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
500 |
|
501 |
with tab2:
|
502 |
with st.expander("Info and Filters"):
|