James McCool
commited on
Commit
·
cc4018f
1
Parent(s):
13d70ab
Add actual player data mapping in Contest Analysis tab of app.py
Browse files- Integrated 'actual_map' into the player frames by mapping player names to their corresponding actual data from the session state dictionary.
- Enhanced the player experience comparison by including actual performance information, improving the analysis capabilities within the Contest Analysis section.
app.py
CHANGED
|
@@ -374,6 +374,7 @@ if selected_tab == 'Data Load':
|
|
| 374 |
'team_map': st.session_state['team_dict'],
|
| 375 |
'salary_map': st.session_state['salary_dict'],
|
| 376 |
'own_map': st.session_state['ownership_dict'],
|
|
|
|
| 377 |
'own_percent_rank': dict(zip(st.session_state['ownership_df']['Player'], st.session_state['ownership_df']['Own'].rank(pct=True)))
|
| 378 |
}
|
| 379 |
|
|
@@ -771,8 +772,10 @@ if selected_tab == 'Contest Analysis':
|
|
| 771 |
else:
|
| 772 |
hold_frame['Pos'] = hold_frame['Player'].map(st.session_state['map_dict']['pos_map'])
|
| 773 |
hold_frame['Salary'] = hold_frame['Player'].map(st.session_state['map_dict']['salary_map'])
|
|
|
|
| 774 |
player_exp_comp.insert(1, 'Pos', hold_frame['Pos'])
|
| 775 |
player_exp_comp.insert(2, 'Salary', hold_frame['Salary'])
|
|
|
|
| 776 |
player_exp_comp = player_exp_comp.dropna(subset=['Pos'])
|
| 777 |
if pos_select:
|
| 778 |
position_mask = player_exp_comp['Pos'].apply(lambda x: any(pos in x for pos in pos_select))
|
|
@@ -791,8 +794,10 @@ if selected_tab == 'Contest Analysis':
|
|
| 791 |
else:
|
| 792 |
hold_frame['Pos'] = hold_frame['Player'].map(st.session_state['map_dict']['pos_map'])
|
| 793 |
hold_frame['Salary'] = hold_frame['Player'].map(st.session_state['map_dict']['salary_map'])
|
|
|
|
| 794 |
st.session_state['player_frame'].insert(1, 'Pos', hold_frame['Pos'])
|
| 795 |
st.session_state['player_frame'].insert(2, 'Salary', hold_frame['Salary'])
|
|
|
|
| 796 |
st.session_state['player_frame'] = st.session_state['player_frame'].dropna(subset=['Pos'])
|
| 797 |
if pos_select:
|
| 798 |
position_mask = st.session_state['player_frame']['Pos'].apply(lambda x: any(pos in x for pos in pos_select))
|
|
@@ -800,7 +805,7 @@ if selected_tab == 'Contest Analysis':
|
|
| 800 |
st.dataframe(st.session_state['player_frame'].
|
| 801 |
sort_values(by='Exposure Overall', ascending=False).
|
| 802 |
style.background_gradient(cmap='RdYlGn').
|
| 803 |
-
format(formatter='{:.2%}', subset=st.session_state['player_frame'].iloc[:,
|
| 804 |
hide_index=True)
|
| 805 |
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", key='player_exp_comp_download')
|
| 806 |
else:
|
|
@@ -815,6 +820,8 @@ if selected_tab == 'Contest Analysis':
|
|
| 815 |
st.session_state['player_frame'].insert(1, 'Pos', hold_frame['Pos'])
|
| 816 |
hold_frame['Salary'] = hold_frame['Player'].map(st.session_state['map_dict']['salary_map'])
|
| 817 |
st.session_state['player_frame'].insert(2, 'Salary', hold_frame['Salary'])
|
|
|
|
|
|
|
| 818 |
st.session_state['player_frame'] = st.session_state['player_frame'].dropna(subset=['Pos'])
|
| 819 |
if pos_select:
|
| 820 |
position_mask = st.session_state['player_frame']['Pos'].apply(lambda x: any(pos in x for pos in pos_select))
|
|
@@ -822,7 +829,7 @@ if selected_tab == 'Contest Analysis':
|
|
| 822 |
st.dataframe(st.session_state['player_frame'].
|
| 823 |
sort_values(by='Exposure Overall', ascending=False).
|
| 824 |
style.background_gradient(cmap='RdYlGn').
|
| 825 |
-
format(formatter='{:.2%}', subset=st.session_state['player_frame'].iloc[:,
|
| 826 |
hide_index=True)
|
| 827 |
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", key='player_exp_comp_download')
|
| 828 |
with tab2:
|
|
|
|
| 374 |
'team_map': st.session_state['team_dict'],
|
| 375 |
'salary_map': st.session_state['salary_dict'],
|
| 376 |
'own_map': st.session_state['ownership_dict'],
|
| 377 |
+
'actual_map': st.session_state['actual_dict'],
|
| 378 |
'own_percent_rank': dict(zip(st.session_state['ownership_df']['Player'], st.session_state['ownership_df']['Own'].rank(pct=True)))
|
| 379 |
}
|
| 380 |
|
|
|
|
| 772 |
else:
|
| 773 |
hold_frame['Pos'] = hold_frame['Player'].map(st.session_state['map_dict']['pos_map'])
|
| 774 |
hold_frame['Salary'] = hold_frame['Player'].map(st.session_state['map_dict']['salary_map'])
|
| 775 |
+
hold_frame['Actual'] = hold_frame['Player'].map(st.session_state['map_dict']['actual_map'])
|
| 776 |
player_exp_comp.insert(1, 'Pos', hold_frame['Pos'])
|
| 777 |
player_exp_comp.insert(2, 'Salary', hold_frame['Salary'])
|
| 778 |
+
player_exp_comp.insert(3, 'Actual', hold_frame['Actual'])
|
| 779 |
player_exp_comp = player_exp_comp.dropna(subset=['Pos'])
|
| 780 |
if pos_select:
|
| 781 |
position_mask = player_exp_comp['Pos'].apply(lambda x: any(pos in x for pos in pos_select))
|
|
|
|
| 794 |
else:
|
| 795 |
hold_frame['Pos'] = hold_frame['Player'].map(st.session_state['map_dict']['pos_map'])
|
| 796 |
hold_frame['Salary'] = hold_frame['Player'].map(st.session_state['map_dict']['salary_map'])
|
| 797 |
+
hold_frame['Actual'] = hold_frame['Player'].map(st.session_state['map_dict']['actual_map'])
|
| 798 |
st.session_state['player_frame'].insert(1, 'Pos', hold_frame['Pos'])
|
| 799 |
st.session_state['player_frame'].insert(2, 'Salary', hold_frame['Salary'])
|
| 800 |
+
st.session_state['player_frame'].insert(3, 'Actual', hold_frame['Actual'])
|
| 801 |
st.session_state['player_frame'] = st.session_state['player_frame'].dropna(subset=['Pos'])
|
| 802 |
if pos_select:
|
| 803 |
position_mask = st.session_state['player_frame']['Pos'].apply(lambda x: any(pos in x for pos in pos_select))
|
|
|
|
| 805 |
st.dataframe(st.session_state['player_frame'].
|
| 806 |
sort_values(by='Exposure Overall', ascending=False).
|
| 807 |
style.background_gradient(cmap='RdYlGn').
|
| 808 |
+
format(formatter='{:.2%}', subset=st.session_state['player_frame'].iloc[:, 4:].select_dtypes(include=['number']).columns),
|
| 809 |
hide_index=True)
|
| 810 |
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", key='player_exp_comp_download')
|
| 811 |
else:
|
|
|
|
| 820 |
st.session_state['player_frame'].insert(1, 'Pos', hold_frame['Pos'])
|
| 821 |
hold_frame['Salary'] = hold_frame['Player'].map(st.session_state['map_dict']['salary_map'])
|
| 822 |
st.session_state['player_frame'].insert(2, 'Salary', hold_frame['Salary'])
|
| 823 |
+
hold_frame['Actual'] = hold_frame['Player'].map(st.session_state['map_dict']['actual_map'])
|
| 824 |
+
st.session_state['player_frame'].insert(3, 'Actual', hold_frame['Actual'])
|
| 825 |
st.session_state['player_frame'] = st.session_state['player_frame'].dropna(subset=['Pos'])
|
| 826 |
if pos_select:
|
| 827 |
position_mask = st.session_state['player_frame']['Pos'].apply(lambda x: any(pos in x for pos in pos_select))
|
|
|
|
| 829 |
st.dataframe(st.session_state['player_frame'].
|
| 830 |
sort_values(by='Exposure Overall', ascending=False).
|
| 831 |
style.background_gradient(cmap='RdYlGn').
|
| 832 |
+
format(formatter='{:.2%}', subset=st.session_state['player_frame'].iloc[:, 4:].select_dtypes(include=['number']).columns),
|
| 833 |
hide_index=True)
|
| 834 |
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", key='player_exp_comp_download')
|
| 835 |
with tab2:
|