James McCool
commited on
Commit
·
8913211
1
Parent(s):
dce062f
testing exposure management with specific column selections
Browse files- app.py +3 -2
- global_func/exposure_spread.py +18 -7
app.py
CHANGED
|
@@ -1882,6 +1882,7 @@ if selected_tab == 'Manage Portfolio':
|
|
| 1882 |
ignore_stacks = []
|
| 1883 |
remove_teams_exposure = st.multiselect("Removed/Locked teams?", options=sorted(list(set(st.session_state['projections_df']['team'].unique()))), default=[])
|
| 1884 |
specific_replacements = st.multiselect("Specific Replacements?", options=sorted(list(set(st.session_state['projections_df']['player_names'].unique()))), default=[])
|
|
|
|
| 1885 |
submitted_col, export_col = st.columns(2)
|
| 1886 |
st.info("Portfolio Button applies to your overall Portfolio, Export button applies to your Custom Export")
|
| 1887 |
with submitted_col:
|
|
@@ -1891,7 +1892,7 @@ if selected_tab == 'Manage Portfolio':
|
|
| 1891 |
if reg_submitted:
|
| 1892 |
st.session_state['settings_base'] = False
|
| 1893 |
prior_frame = st.session_state['working_frame'].copy()
|
| 1894 |
-
parsed_frame = exposure_spread(st.session_state['working_frame'], st.session_state['exposure_player'], exposure_target, ignore_stacks, remove_teams_exposure, specific_replacements, st.session_state['projections_df'], sport_var, type_var, salary_max, stacking_sports)
|
| 1895 |
|
| 1896 |
if type_var == 'Classic':
|
| 1897 |
if sport_var == 'CS2' or sport_var == 'LOL':
|
|
@@ -1984,7 +1985,7 @@ if selected_tab == 'Manage Portfolio':
|
|
| 1984 |
elif exp_submitted:
|
| 1985 |
st.session_state['settings_base'] = False
|
| 1986 |
prior_frame = st.session_state['export_base'].copy()
|
| 1987 |
-
parsed_frame = exposure_spread(st.session_state['export_base'], st.session_state['exposure_player'], exposure_target, ignore_stacks, remove_teams_exposure, specific_replacements, st.session_state['projections_df'], sport_var, type_var, salary_max, stacking_sports)
|
| 1988 |
|
| 1989 |
if type_var == 'Classic':
|
| 1990 |
if sport_var == 'CS2' or sport_var == 'LOL':
|
|
|
|
| 1882 |
ignore_stacks = []
|
| 1883 |
remove_teams_exposure = st.multiselect("Removed/Locked teams?", options=sorted(list(set(st.session_state['projections_df']['team'].unique()))), default=[])
|
| 1884 |
specific_replacements = st.multiselect("Specific Replacements?", options=sorted(list(set(st.session_state['projections_df']['player_names'].unique()))), default=[])
|
| 1885 |
+
specific_columns = st.multiselect("Specific Positions?", options=sorted(list(st.session_state['working_frame'].columns)), default=[])
|
| 1886 |
submitted_col, export_col = st.columns(2)
|
| 1887 |
st.info("Portfolio Button applies to your overall Portfolio, Export button applies to your Custom Export")
|
| 1888 |
with submitted_col:
|
|
|
|
| 1892 |
if reg_submitted:
|
| 1893 |
st.session_state['settings_base'] = False
|
| 1894 |
prior_frame = st.session_state['working_frame'].copy()
|
| 1895 |
+
parsed_frame = exposure_spread(st.session_state['working_frame'], st.session_state['exposure_player'], exposure_target, ignore_stacks, remove_teams_exposure, specific_replacements, specific_columns, st.session_state['projections_df'], sport_var, type_var, salary_max, stacking_sports)
|
| 1896 |
|
| 1897 |
if type_var == 'Classic':
|
| 1898 |
if sport_var == 'CS2' or sport_var == 'LOL':
|
|
|
|
| 1985 |
elif exp_submitted:
|
| 1986 |
st.session_state['settings_base'] = False
|
| 1987 |
prior_frame = st.session_state['export_base'].copy()
|
| 1988 |
+
parsed_frame = exposure_spread(st.session_state['export_base'], st.session_state['exposure_player'], exposure_target, ignore_stacks, remove_teams_exposure, specific_replacements, specific_columns, st.session_state['projections_df'], sport_var, type_var, salary_max, stacking_sports)
|
| 1989 |
|
| 1990 |
if type_var == 'Classic':
|
| 1991 |
if sport_var == 'CS2' or sport_var == 'LOL':
|
global_func/exposure_spread.py
CHANGED
|
@@ -148,7 +148,7 @@ def check_position_eligibility(sport, column_name, player_positions):
|
|
| 148 |
# Default fallback - assume exact position match
|
| 149 |
return column_name in player_positions
|
| 150 |
|
| 151 |
-
def exposure_spread(working_frame, exposure_player, exposure_target, ignore_stacks, remove_teams, specific_replacements, projections_df, sport_var, type_var, salary_max, stacking_sports):
|
| 152 |
comparable_players = projections_df[projections_df['player_names'] == exposure_player]
|
| 153 |
|
| 154 |
comparable_players = comparable_players.reset_index(drop=True)
|
|
@@ -172,12 +172,23 @@ def exposure_spread(working_frame, exposure_player, exposure_target, ignore_stac
|
|
| 172 |
return any(pos in target_positions for pos in player_pos_list)
|
| 173 |
|
| 174 |
# find the exposure rate of the player in the working frame
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
|
| 182 |
player_exposure = player_mask.sum() / len(working_frame)
|
| 183 |
replace_exposure = replace_mask.sum() / len(working_frame)
|
|
|
|
| 148 |
# Default fallback - assume exact position match
|
| 149 |
return column_name in player_positions
|
| 150 |
|
| 151 |
+
def exposure_spread(working_frame, exposure_player, exposure_target, ignore_stacks, remove_teams, specific_replacements, specific_columns, projections_df, sport_var, type_var, salary_max, stacking_sports):
|
| 152 |
comparable_players = projections_df[projections_df['player_names'] == exposure_player]
|
| 153 |
|
| 154 |
comparable_players = comparable_players.reset_index(drop=True)
|
|
|
|
| 172 |
return any(pos in target_positions for pos in player_pos_list)
|
| 173 |
|
| 174 |
# find the exposure rate of the player in the working frame
|
| 175 |
+
if specific_columns != []:
|
| 176 |
+
player_mask = working_frame[specific_columns].apply(
|
| 177 |
+
lambda row: exposure_player in list(row), axis=1
|
| 178 |
+
)
|
| 179 |
+
else:
|
| 180 |
+
player_mask = working_frame[working_frame.columns].apply(
|
| 181 |
+
lambda row: exposure_player in list(row), axis=1
|
| 182 |
+
)
|
| 183 |
+
|
| 184 |
+
if specific_columns != []:
|
| 185 |
+
replace_mask = working_frame[specific_columns].apply(
|
| 186 |
+
lambda row: exposure_player not in list(row), axis=1
|
| 187 |
+
)
|
| 188 |
+
else:
|
| 189 |
+
replace_mask = working_frame[working_frame.columns].apply(
|
| 190 |
+
lambda row: exposure_player not in list(row), axis=1
|
| 191 |
+
)
|
| 192 |
|
| 193 |
player_exposure = player_mask.sum() / len(working_frame)
|
| 194 |
replace_exposure = replace_mask.sum() / len(working_frame)
|