Spaces:
Running
Running
James McCool
commited on
Commit
·
023a185
1
Parent(s):
4723d1e
Refactor data export logic in app.py: streamline the export process by removing redundant mapping for player position columns and ensuring accurate filtering of entries based on salary range. Update Portfolio Manager exports to reflect these changes, enhancing data clarity and user experience.
Browse files
app.py
CHANGED
@@ -627,6 +627,8 @@ with tab2:
|
|
627 |
data_export[col_idx] = data_export[col_idx].map(id_dict)
|
628 |
elif slate_type_var1 == 'Showdown':
|
629 |
data_export[col_idx] = data_export[col_idx].map(fd_id_dict_sd)
|
|
|
|
|
630 |
reg_opt_col, pm_opt_col = st.columns(2)
|
631 |
with reg_opt_col:
|
632 |
st.download_button(
|
@@ -662,36 +664,17 @@ with tab2:
|
|
662 |
map_columns = ['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4']
|
663 |
for col_idx in map_columns:
|
664 |
data_export[col_idx] = data_export[col_idx].map(id_dict)
|
|
|
|
|
665 |
st.download_button(
|
666 |
label="Portfolio Manager Export (IDs)",
|
667 |
-
data=convert_pm_df(
|
668 |
file_name='NBA_optimals_export.csv',
|
669 |
mime='text/csv',
|
670 |
)
|
671 |
-
|
672 |
-
if site_var2 == 'Draftkings':
|
673 |
-
if slate_type_var1 == 'Regular':
|
674 |
-
if league_var == 'NBA':
|
675 |
-
map_columns = ['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'FLEX']
|
676 |
-
elif league_var == 'WNBA':
|
677 |
-
map_columns = ['G1', 'G2', 'F1', 'F2', 'F3', 'UTIL']
|
678 |
-
elif slate_type_var1 == 'Showdown':
|
679 |
-
map_columns = ['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5']
|
680 |
-
for col_idx in map_columns:
|
681 |
-
name_export[col_idx] = name_export[col_idx].map(id_dict)
|
682 |
-
elif site_var2 == 'Fanduel':
|
683 |
-
if slate_type_var1 == 'Regular':
|
684 |
-
if league_var == 'NBA':
|
685 |
-
map_columns = ['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1', 'C2', 'UTIL']
|
686 |
-
elif league_var == 'WNBA':
|
687 |
-
map_columns = ['G1', 'G2', 'G3', 'F1', 'F2', 'F3', 'F4']
|
688 |
-
elif slate_type_var1 == 'Showdown':
|
689 |
-
map_columns = ['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4']
|
690 |
-
for col_idx in map_columns:
|
691 |
-
name_export[col_idx] = name_export[col_idx].map(id_dict)
|
692 |
st.download_button(
|
693 |
label="Portfolio Manager Export (Names)",
|
694 |
-
data=convert_pm_df(
|
695 |
file_name='NBA_optimals_export.csv',
|
696 |
mime='text/csv',
|
697 |
)
|
@@ -730,7 +713,10 @@ with tab2:
|
|
730 |
|
731 |
name_export = name_export[name_export['salary'] >= salary_min_var]
|
732 |
name_export = name_export[name_export['salary'] <= salary_max_var]
|
733 |
-
|
|
|
|
|
|
|
734 |
reg_opt_col, pm_opt_col = st.columns(2)
|
735 |
with reg_opt_col:
|
736 |
st.download_button(
|
@@ -762,32 +748,25 @@ with tab2:
|
|
762 |
data_export = data_export.drop(columns=['salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own'], axis=1)
|
763 |
elif slate_type_var1 == 'Showdown':
|
764 |
data_export = data_export.drop(columns=['salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own'], axis=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
765 |
st.download_button(
|
766 |
label="Portfolio Manager Export (IDs)",
|
767 |
-
data=convert_pm_df(
|
768 |
file_name='NBA_optimals_export.csv',
|
769 |
mime='text/csv',
|
770 |
)
|
771 |
-
|
772 |
-
if site_var2 == 'Draftkings':
|
773 |
-
if slate_type_var1 == 'Regular':
|
774 |
-
if league_var == 'NBA':
|
775 |
-
name_export = name_export.drop(columns=['salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own'], axis=1)
|
776 |
-
elif league_var == 'WNBA':
|
777 |
-
name_export = name_export.drop(columns=['salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own'], axis=1)
|
778 |
-
elif slate_type_var1 == 'Showdown':
|
779 |
-
name_export = name_export.drop(columns=['salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own'], axis=1)
|
780 |
-
elif site_var2 == 'Fanduel':
|
781 |
-
if slate_type_var1 == 'Regular':
|
782 |
-
if league_var == 'NBA':
|
783 |
-
name_export = name_export.drop(columns=['salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own'], axis=1)
|
784 |
-
elif league_var == 'WNBA':
|
785 |
-
name_export = name_export.drop(columns=['salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own'], axis=1)
|
786 |
-
elif slate_type_var1 == 'Showdown':
|
787 |
-
name_export = name_export.drop(columns=['salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own'], axis=1)
|
788 |
st.download_button(
|
789 |
label="Portfolio Manager Export (Names)",
|
790 |
-
data=convert_pm_df(
|
791 |
file_name='NBA_optimals_export.csv',
|
792 |
mime='text/csv',
|
793 |
)
|
|
|
627 |
data_export[col_idx] = data_export[col_idx].map(id_dict)
|
628 |
elif slate_type_var1 == 'Showdown':
|
629 |
data_export[col_idx] = data_export[col_idx].map(fd_id_dict_sd)
|
630 |
+
name_export = name_export
|
631 |
+
data_export = data_export
|
632 |
reg_opt_col, pm_opt_col = st.columns(2)
|
633 |
with reg_opt_col:
|
634 |
st.download_button(
|
|
|
664 |
map_columns = ['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4']
|
665 |
for col_idx in map_columns:
|
666 |
data_export[col_idx] = data_export[col_idx].map(id_dict)
|
667 |
+
pm_name_export = name_export.drop(columns=['salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own'], axis=1)
|
668 |
+
pm_data_export = data_export.drop(columns=['salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own'], axis=1)
|
669 |
st.download_button(
|
670 |
label="Portfolio Manager Export (IDs)",
|
671 |
+
data=convert_pm_df(pm_data_export),
|
672 |
file_name='NBA_optimals_export.csv',
|
673 |
mime='text/csv',
|
674 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
675 |
st.download_button(
|
676 |
label="Portfolio Manager Export (Names)",
|
677 |
+
data=convert_pm_df(pm_name_export),
|
678 |
file_name='NBA_optimals_export.csv',
|
679 |
mime='text/csv',
|
680 |
)
|
|
|
713 |
|
714 |
name_export = name_export[name_export['salary'] >= salary_min_var]
|
715 |
name_export = name_export[name_export['salary'] <= salary_max_var]
|
716 |
+
|
717 |
+
data_export = data_export
|
718 |
+
name_export = name_export
|
719 |
+
|
720 |
reg_opt_col, pm_opt_col = st.columns(2)
|
721 |
with reg_opt_col:
|
722 |
st.download_button(
|
|
|
748 |
data_export = data_export.drop(columns=['salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own'], axis=1)
|
749 |
elif slate_type_var1 == 'Showdown':
|
750 |
data_export = data_export.drop(columns=['salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own'], axis=1)
|
751 |
+
|
752 |
+
data_export = data_export[data_export['salary'] >= salary_min_var]
|
753 |
+
data_export = data_export[data_export['salary'] <= salary_max_var]
|
754 |
+
|
755 |
+
name_export = name_export[name_export['salary'] >= salary_min_var]
|
756 |
+
name_export = name_export[name_export['salary'] <= salary_max_var]
|
757 |
+
|
758 |
+
pm_name_export = name_export.drop(columns=['salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own'], axis=1)
|
759 |
+
pm_data_export = data_export.drop(columns=['salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own'], axis=1)
|
760 |
+
|
761 |
st.download_button(
|
762 |
label="Portfolio Manager Export (IDs)",
|
763 |
+
data=convert_pm_df(pm_data_export),
|
764 |
file_name='NBA_optimals_export.csv',
|
765 |
mime='text/csv',
|
766 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
767 |
st.download_button(
|
768 |
label="Portfolio Manager Export (Names)",
|
769 |
+
data=convert_pm_df(pm_name_export),
|
770 |
file_name='NBA_optimals_export.csv',
|
771 |
mime='text/csv',
|
772 |
)
|