Merge branch 'main' of https://huggingface.co/spaces/Multichem-PD/DFS_Portfolio_Manager
Browse files
app.py
CHANGED
|
@@ -162,7 +162,20 @@ with tab1:
|
|
| 162 |
st.write('replaced salary symbols')
|
| 163 |
except:
|
| 164 |
pass
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 165 |
projections['salary'] = projections['salary'].dropna().astype(int)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
projections = projections.apply(lambda x: x.replace(player_wrong_names_mlb, player_right_names_mlb))
|
| 167 |
st.dataframe(projections.head(10))
|
| 168 |
|
|
@@ -250,7 +263,7 @@ with tab1:
|
|
| 250 |
projections['player_names'] = projections['player_names'].map(lambda x: projections_match_dict.get(x, x))
|
| 251 |
st.session_state['projections_df'] = projections
|
| 252 |
|
| 253 |
-
if
|
| 254 |
team_dict = dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['team']))
|
| 255 |
st.session_state['portfolio']['Stack'] = st.session_state['portfolio'].apply(
|
| 256 |
lambda row: Counter(
|
|
@@ -825,17 +838,30 @@ with tab2:
|
|
| 825 |
'cpt_own_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['captain ownership']))
|
| 826 |
}
|
| 827 |
elif type_var == 'Showdown':
|
| 828 |
-
|
| 829 |
-
|
| 830 |
-
|
| 831 |
-
|
| 832 |
-
|
| 833 |
-
|
| 834 |
-
|
| 835 |
-
|
| 836 |
-
|
| 837 |
-
|
| 838 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 839 |
elif site_var == 'Fanduel':
|
| 840 |
st.session_state['map_dict'] = {
|
| 841 |
'pos_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['position'])),
|
|
|
|
| 162 |
st.write('replaced salary symbols')
|
| 163 |
except:
|
| 164 |
pass
|
| 165 |
+
try:
|
| 166 |
+
projections['ownership'] = projections['ownership'].str.replace('%', '').str.replace(' ', '')
|
| 167 |
+
st.write('replaced ownership symbols')
|
| 168 |
+
except:
|
| 169 |
+
pass
|
| 170 |
projections['salary'] = projections['salary'].dropna().astype(int)
|
| 171 |
+
projections['ownership'] = projections['ownership'].astype(float)
|
| 172 |
+
if type_var == 'Showdown':
|
| 173 |
+
if projections['captain ownership'].isna().all():
|
| 174 |
+
projections['CPT_Own_raw'] = (projections['ownership'] / 2) * ((100 - (100-projections['ownership']))/100)
|
| 175 |
+
cpt_own_var = 100 / projections['CPT_Own_raw'].sum()
|
| 176 |
+
projections['captain ownership'] = projections['CPT_Own_raw'] * cpt_own_var
|
| 177 |
+
projections = projections.drop(columns='CPT_Own_raw', axis=1)
|
| 178 |
+
|
| 179 |
projections = projections.apply(lambda x: x.replace(player_wrong_names_mlb, player_right_names_mlb))
|
| 180 |
st.dataframe(projections.head(10))
|
| 181 |
|
|
|
|
| 263 |
projections['player_names'] = projections['player_names'].map(lambda x: projections_match_dict.get(x, x))
|
| 264 |
st.session_state['projections_df'] = projections
|
| 265 |
|
| 266 |
+
if sport_var in stacking_sports:
|
| 267 |
team_dict = dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['team']))
|
| 268 |
st.session_state['portfolio']['Stack'] = st.session_state['portfolio'].apply(
|
| 269 |
lambda row: Counter(
|
|
|
|
| 838 |
'cpt_own_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['captain ownership']))
|
| 839 |
}
|
| 840 |
elif type_var == 'Showdown':
|
| 841 |
+
if sport_var == 'GOLF':
|
| 842 |
+
st.session_state['map_dict'] = {
|
| 843 |
+
'pos_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['position'])),
|
| 844 |
+
'team_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['team'])),
|
| 845 |
+
'salary_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['salary'])),
|
| 846 |
+
'proj_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['median'])),
|
| 847 |
+
'own_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['ownership'])),
|
| 848 |
+
'own_percent_rank':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['ownership'].rank(pct=True))),
|
| 849 |
+
'cpt_salary_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['salary'])),
|
| 850 |
+
'cpt_proj_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['median'])),
|
| 851 |
+
'cpt_own_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['ownership']))
|
| 852 |
+
}
|
| 853 |
+
if sport_var != 'GOLF':
|
| 854 |
+
st.session_state['map_dict'] = {
|
| 855 |
+
'pos_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['position'])),
|
| 856 |
+
'team_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['team'])),
|
| 857 |
+
'salary_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['salary'])),
|
| 858 |
+
'proj_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['median'])),
|
| 859 |
+
'own_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['ownership'])),
|
| 860 |
+
'own_percent_rank':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['ownership'].rank(pct=True))),
|
| 861 |
+
'cpt_salary_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['salary'] * 1.5)),
|
| 862 |
+
'cpt_proj_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['median'] * 1.5)),
|
| 863 |
+
'cpt_own_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['captain ownership']))
|
| 864 |
+
}
|
| 865 |
elif site_var == 'Fanduel':
|
| 866 |
st.session_state['map_dict'] = {
|
| 867 |
'pos_map':dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['position'])),
|