James McCool
commited on
Commit
·
219079c
1
Parent(s):
8181002
Add download buttons for player, stack, size, general, and duplication info in app.py
Browse files- Implemented download buttons for exporting player, stack, size, general, and duplication information as CSV files, enhancing data accessibility and user experience across multiple sections of the application.
app.py
CHANGED
|
@@ -502,6 +502,7 @@ with tab2:
|
|
| 502 |
position_mask = player_exp_comp['Pos'].apply(lambda x: any(pos in x for pos in pos_select))
|
| 503 |
player_exp_comp = player_exp_comp[position_mask]
|
| 504 |
st.dataframe(player_exp_comp.style.background_gradient(cmap='RdYlGn', axis=0).format(formatter='{:.2%}', subset=player_exp_comp.select_dtypes(include=['number']).columns), hide_index=True)
|
|
|
|
| 505 |
else:
|
| 506 |
if st.session_state['entry_parse_var'] == 'All':
|
| 507 |
|
|
@@ -521,6 +522,7 @@ with tab2:
|
|
| 521 |
style.background_gradient(cmap='RdYlGn').
|
| 522 |
format(formatter='{:.2%}', subset=st.session_state['player_frame'].iloc[:, 2:].select_dtypes(include=['number']).columns),
|
| 523 |
hide_index=True)
|
|
|
|
| 524 |
else:
|
| 525 |
st.session_state['player_frame'] = create_player_exposures(st.session_state['display_contest_info'], st.session_state['player_columns'], st.session_state['entry_names'])
|
| 526 |
hold_frame = st.session_state['player_frame'].copy()
|
|
@@ -538,6 +540,7 @@ with tab2:
|
|
| 538 |
style.background_gradient(cmap='RdYlGn').
|
| 539 |
format(formatter='{:.2%}', subset=st.session_state['player_frame'].iloc[:, 2:].select_dtypes(include=['number']).columns),
|
| 540 |
hide_index=True)
|
|
|
|
| 541 |
with tab2:
|
| 542 |
with st.form(key='stack_exp_comp_form'):
|
| 543 |
col1, col2 = st.columns(2)
|
|
@@ -554,6 +557,7 @@ with tab2:
|
|
| 554 |
if comp_stack_var == 'Yes':
|
| 555 |
stack_exp_comp = create_stack_comparison(st.session_state['display_contest_info'], comp_stack_select)
|
| 556 |
st.dataframe(stack_exp_comp.style.background_gradient(cmap='RdYlGn', axis=0).format(formatter='{:.2%}', subset=stack_exp_comp.select_dtypes(include=['number']).columns), hide_index=True)
|
|
|
|
| 557 |
else:
|
| 558 |
if st.session_state['entry_parse_var'] == 'All':
|
| 559 |
st.session_state['stack_frame'] = create_stack_exposures(st.session_state['display_contest_info'])
|
|
@@ -562,6 +566,7 @@ with tab2:
|
|
| 562 |
style.background_gradient(cmap='RdYlGn').
|
| 563 |
format(formatter='{:.2%}', subset=st.session_state['stack_frame'].iloc[:, 1:].select_dtypes(include=['number']).columns),
|
| 564 |
hide_index=True)
|
|
|
|
| 565 |
else:
|
| 566 |
st.session_state['stack_frame'] = create_stack_exposures(st.session_state['display_contest_info'], st.session_state['entry_names'])
|
| 567 |
st.dataframe(st.session_state['stack_frame'].
|
|
@@ -569,6 +574,7 @@ with tab2:
|
|
| 569 |
style.background_gradient(cmap='RdYlGn').
|
| 570 |
format(formatter='{:.2%}', subset=st.session_state['stack_frame'].iloc[:, 1:].select_dtypes(include=['number']).columns),
|
| 571 |
hide_index=True)
|
|
|
|
| 572 |
with tab3:
|
| 573 |
with st.form(key='size_exp_comp_form'):
|
| 574 |
col1, col2 = st.columns(2)
|
|
@@ -585,6 +591,7 @@ with tab2:
|
|
| 585 |
if comp_size_var == 'Yes':
|
| 586 |
size_exp_comp = create_size_comparison(st.session_state['display_contest_info'], comp_size_select)
|
| 587 |
st.dataframe(size_exp_comp.style.background_gradient(cmap='RdYlGn', axis=0).format(formatter='{:.2%}', subset=size_exp_comp.select_dtypes(include=['number']).columns), hide_index=True)
|
|
|
|
| 588 |
else:
|
| 589 |
if st.session_state['entry_parse_var'] == 'All':
|
| 590 |
st.session_state['stack_size_frame'] = create_stack_size_exposures(st.session_state['display_contest_info'])
|
|
@@ -593,6 +600,7 @@ with tab2:
|
|
| 593 |
style.background_gradient(cmap='RdYlGn').
|
| 594 |
format(formatter='{:.2%}', subset=st.session_state['stack_size_frame'].iloc[:, 1:].select_dtypes(include=['number']).columns),
|
| 595 |
hide_index=True)
|
|
|
|
| 596 |
else:
|
| 597 |
st.session_state['stack_size_frame'] = create_stack_size_exposures(st.session_state['display_contest_info'], st.session_state['entry_names'])
|
| 598 |
# st.session_state['stack_size_frame']['Player'] = st.session_state['stack_size_frame']['Player'].astype(str)
|
|
@@ -601,7 +609,7 @@ with tab2:
|
|
| 601 |
style.background_gradient(cmap='RdYlGn').
|
| 602 |
format(formatter='{:.2%}', subset=st.session_state['stack_size_frame'].iloc[:, 1:].select_dtypes(include=['number']).columns),
|
| 603 |
hide_index=True)
|
| 604 |
-
|
| 605 |
with tab4:
|
| 606 |
with st.form(key='general_comp_form'):
|
| 607 |
col1, col2 = st.columns(2)
|
|
@@ -618,14 +626,16 @@ with tab2:
|
|
| 618 |
if comp_general_var == 'Yes':
|
| 619 |
general_comp = create_general_comparison(st.session_state['display_contest_info'], comp_general_select)
|
| 620 |
st.dataframe(general_comp.style.background_gradient(cmap='RdYlGn', axis=1).format(precision=2))
|
|
|
|
| 621 |
else:
|
| 622 |
if st.session_state['entry_parse_var'] == 'All':
|
| 623 |
st.session_state['general_frame'] = create_general_exposures(st.session_state['display_contest_info'])
|
| 624 |
st.dataframe(st.session_state['general_frame'].style.background_gradient(cmap='RdYlGn', axis=1).format(precision=2), hide_index=True)
|
| 625 |
-
|
| 626 |
else:
|
| 627 |
st.session_state['general_frame'] = create_general_exposures(st.session_state['display_contest_info'], st.session_state['entry_names'])
|
| 628 |
st.dataframe(st.session_state['general_frame'].style.background_gradient(cmap='RdYlGn', axis=1).format(precision=2), hide_index=True)
|
|
|
|
| 629 |
|
| 630 |
with tab5:
|
| 631 |
with st.form(key='dupe_form'):
|
|
@@ -678,4 +688,5 @@ with tab2:
|
|
| 678 |
st.dataframe(st.session_state['duplication_frame'].iloc[start_dupe_idx:end_dupe_idx].style.
|
| 679 |
background_gradient(cmap='RdYlGn', subset=['uniques%', 'under_5%', 'under_10%'], axis=0).
|
| 680 |
background_gradient(cmap='RdYlGn', subset=['uniques', 'under_5', 'under_10'], axis=0).
|
| 681 |
-
format(dupe_format, precision=2), hide_index=True)
|
|
|
|
|
|
| 502 |
position_mask = player_exp_comp['Pos'].apply(lambda x: any(pos in x for pos in pos_select))
|
| 503 |
player_exp_comp = player_exp_comp[position_mask]
|
| 504 |
st.dataframe(player_exp_comp.style.background_gradient(cmap='RdYlGn', axis=0).format(formatter='{:.2%}', subset=player_exp_comp.select_dtypes(include=['number']).columns), hide_index=True)
|
| 505 |
+
st.download_button(label="Download Player Info", data=player_exp_comp.to_csv(index=False), file_name="player_info.csv", mime="text/csv")
|
| 506 |
else:
|
| 507 |
if st.session_state['entry_parse_var'] == 'All':
|
| 508 |
|
|
|
|
| 522 |
style.background_gradient(cmap='RdYlGn').
|
| 523 |
format(formatter='{:.2%}', subset=st.session_state['player_frame'].iloc[:, 2:].select_dtypes(include=['number']).columns),
|
| 524 |
hide_index=True)
|
| 525 |
+
st.download_button(label="Download Player Info", data=st.session_state['player_frame'].to_csv(index=False), file_name="player_info.csv", mime="text/csv")
|
| 526 |
else:
|
| 527 |
st.session_state['player_frame'] = create_player_exposures(st.session_state['display_contest_info'], st.session_state['player_columns'], st.session_state['entry_names'])
|
| 528 |
hold_frame = st.session_state['player_frame'].copy()
|
|
|
|
| 540 |
style.background_gradient(cmap='RdYlGn').
|
| 541 |
format(formatter='{:.2%}', subset=st.session_state['player_frame'].iloc[:, 2:].select_dtypes(include=['number']).columns),
|
| 542 |
hide_index=True)
|
| 543 |
+
st.download_button(label="Download Player Info", data=st.session_state['player_frame'].to_csv(index=False), file_name="player_info.csv", mime="text/csv")
|
| 544 |
with tab2:
|
| 545 |
with st.form(key='stack_exp_comp_form'):
|
| 546 |
col1, col2 = st.columns(2)
|
|
|
|
| 557 |
if comp_stack_var == 'Yes':
|
| 558 |
stack_exp_comp = create_stack_comparison(st.session_state['display_contest_info'], comp_stack_select)
|
| 559 |
st.dataframe(stack_exp_comp.style.background_gradient(cmap='RdYlGn', axis=0).format(formatter='{:.2%}', subset=stack_exp_comp.select_dtypes(include=['number']).columns), hide_index=True)
|
| 560 |
+
st.download_button(label="Download Stack Info", data=stack_exp_comp.to_csv(index=False), file_name="stack_info.csv", mime="text/csv")
|
| 561 |
else:
|
| 562 |
if st.session_state['entry_parse_var'] == 'All':
|
| 563 |
st.session_state['stack_frame'] = create_stack_exposures(st.session_state['display_contest_info'])
|
|
|
|
| 566 |
style.background_gradient(cmap='RdYlGn').
|
| 567 |
format(formatter='{:.2%}', subset=st.session_state['stack_frame'].iloc[:, 1:].select_dtypes(include=['number']).columns),
|
| 568 |
hide_index=True)
|
| 569 |
+
st.download_button(label="Download Stack Info", data=st.session_state['stack_frame'].to_csv(index=False), file_name="stack_info.csv", mime="text/csv")
|
| 570 |
else:
|
| 571 |
st.session_state['stack_frame'] = create_stack_exposures(st.session_state['display_contest_info'], st.session_state['entry_names'])
|
| 572 |
st.dataframe(st.session_state['stack_frame'].
|
|
|
|
| 574 |
style.background_gradient(cmap='RdYlGn').
|
| 575 |
format(formatter='{:.2%}', subset=st.session_state['stack_frame'].iloc[:, 1:].select_dtypes(include=['number']).columns),
|
| 576 |
hide_index=True)
|
| 577 |
+
st.download_button(label="Download Stack Info", data=st.session_state['stack_frame'].to_csv(index=False), file_name="stack_info.csv", mime="text/csv")
|
| 578 |
with tab3:
|
| 579 |
with st.form(key='size_exp_comp_form'):
|
| 580 |
col1, col2 = st.columns(2)
|
|
|
|
| 591 |
if comp_size_var == 'Yes':
|
| 592 |
size_exp_comp = create_size_comparison(st.session_state['display_contest_info'], comp_size_select)
|
| 593 |
st.dataframe(size_exp_comp.style.background_gradient(cmap='RdYlGn', axis=0).format(formatter='{:.2%}', subset=size_exp_comp.select_dtypes(include=['number']).columns), hide_index=True)
|
| 594 |
+
st.download_button(label="Download Stack Size Info", data=size_exp_comp.to_csv(index=False), file_name="stack_size_info.csv", mime="text/csv")
|
| 595 |
else:
|
| 596 |
if st.session_state['entry_parse_var'] == 'All':
|
| 597 |
st.session_state['stack_size_frame'] = create_stack_size_exposures(st.session_state['display_contest_info'])
|
|
|
|
| 600 |
style.background_gradient(cmap='RdYlGn').
|
| 601 |
format(formatter='{:.2%}', subset=st.session_state['stack_size_frame'].iloc[:, 1:].select_dtypes(include=['number']).columns),
|
| 602 |
hide_index=True)
|
| 603 |
+
st.download_button(label="Download Stack Size Info", data=st.session_state['stack_size_frame'].to_csv(index=False), file_name="stack_size_info.csv", mime="text/csv")
|
| 604 |
else:
|
| 605 |
st.session_state['stack_size_frame'] = create_stack_size_exposures(st.session_state['display_contest_info'], st.session_state['entry_names'])
|
| 606 |
# st.session_state['stack_size_frame']['Player'] = st.session_state['stack_size_frame']['Player'].astype(str)
|
|
|
|
| 609 |
style.background_gradient(cmap='RdYlGn').
|
| 610 |
format(formatter='{:.2%}', subset=st.session_state['stack_size_frame'].iloc[:, 1:].select_dtypes(include=['number']).columns),
|
| 611 |
hide_index=True)
|
| 612 |
+
st.download_button(label="Download Stack Size Info", data=st.session_state['stack_size_frame'].to_csv(index=False), file_name="stack_size_info.csv", mime="text/csv")
|
| 613 |
with tab4:
|
| 614 |
with st.form(key='general_comp_form'):
|
| 615 |
col1, col2 = st.columns(2)
|
|
|
|
| 626 |
if comp_general_var == 'Yes':
|
| 627 |
general_comp = create_general_comparison(st.session_state['display_contest_info'], comp_general_select)
|
| 628 |
st.dataframe(general_comp.style.background_gradient(cmap='RdYlGn', axis=1).format(precision=2))
|
| 629 |
+
st.download_button(label="Download General Info", data=general_comp.to_csv(index=False), file_name="general_info.csv", mime="text/csv")
|
| 630 |
else:
|
| 631 |
if st.session_state['entry_parse_var'] == 'All':
|
| 632 |
st.session_state['general_frame'] = create_general_exposures(st.session_state['display_contest_info'])
|
| 633 |
st.dataframe(st.session_state['general_frame'].style.background_gradient(cmap='RdYlGn', axis=1).format(precision=2), hide_index=True)
|
| 634 |
+
st.download_button(label="Download General Info", data=st.session_state['general_frame'].to_csv(index=False), file_name="general_info.csv", mime="text/csv")
|
| 635 |
else:
|
| 636 |
st.session_state['general_frame'] = create_general_exposures(st.session_state['display_contest_info'], st.session_state['entry_names'])
|
| 637 |
st.dataframe(st.session_state['general_frame'].style.background_gradient(cmap='RdYlGn', axis=1).format(precision=2), hide_index=True)
|
| 638 |
+
st.download_button(label="Download General Info", data=st.session_state['general_frame'].to_csv(index=False), file_name="general_info.csv", mime="text/csv")
|
| 639 |
|
| 640 |
with tab5:
|
| 641 |
with st.form(key='dupe_form'):
|
|
|
|
| 688 |
st.dataframe(st.session_state['duplication_frame'].iloc[start_dupe_idx:end_dupe_idx].style.
|
| 689 |
background_gradient(cmap='RdYlGn', subset=['uniques%', 'under_5%', 'under_10%'], axis=0).
|
| 690 |
background_gradient(cmap='RdYlGn', subset=['uniques', 'under_5', 'under_10'], axis=0).
|
| 691 |
+
format(dupe_format, precision=2), hide_index=True)
|
| 692 |
+
st.download_button(label="Download Duplication Info", data=st.session_state['duplication_frame'].to_csv(index=False), file_name="duplication_info.csv", mime="text/csv")
|