James McCool commited on
Commit
9e53f8f
·
1 Parent(s): 1a4a0d8

Enhance player selection logic in 'exposure_spread' by adding salary constraints for specific replacements, improving accuracy in lineup generation and incorporating error handling for existing players.

Browse files
Files changed (1) hide show
  1. global_func/exposure_spread.py +8 -3
global_func/exposure_spread.py CHANGED
@@ -212,7 +212,8 @@ def exposure_spread(working_frame, exposure_player, exposure_target, ignore_stac
212
  for row in random_row_indices_insert:
213
  if change_counter < math.ceil(lineups_to_remove):
214
  if specific_replacements != []:
215
- comparable_players = projections_df[(projections_df['player_names'].isin(specific_replacements))
 
216
  ]
217
  else:
218
  comparable_players = projections_df[
@@ -236,7 +237,10 @@ def exposure_spread(working_frame, exposure_player, exposure_target, ignore_stac
236
 
237
  # Filter out players that are already present in this row
238
  existing_players = set(current_row_data.values)
239
- comparable_players = comparable_players[~comparable_players['player_names'].isin(existing_players)]
 
 
 
240
 
241
  # Create a list of comparable players
242
  comparable_player_list = comparable_players['player_names'].tolist()
@@ -262,7 +266,8 @@ def exposure_spread(working_frame, exposure_player, exposure_target, ignore_stac
262
  for row in random_row_indices_replace:
263
  if change_counter < math.ceil(lineups_to_add):
264
  if specific_replacements != []:
265
- comparable_players = projections_df[(projections_df['player_names'].isin(specific_replacements))
 
266
  ]
267
  else:
268
  comparable_players = projections_df[
 
212
  for row in random_row_indices_insert:
213
  if change_counter < math.ceil(lineups_to_remove):
214
  if specific_replacements != []:
215
+ comparable_players = projections_df[(projections_df['player_names'].isin(specific_replacements)) &
216
+ (projections_df['salary'] <= comp_salary_high + (salary_max - working_frame['salary'][row]))
217
  ]
218
  else:
219
  comparable_players = projections_df[
 
237
 
238
  # Filter out players that are already present in this row
239
  existing_players = set(current_row_data.values)
240
+ try:
241
+ comparable_players = comparable_players[~comparable_players['player_names'].isin(existing_players)]
242
+ except:
243
+ pass
244
 
245
  # Create a list of comparable players
246
  comparable_player_list = comparable_players['player_names'].tolist()
 
266
  for row in random_row_indices_replace:
267
  if change_counter < math.ceil(lineups_to_add):
268
  if specific_replacements != []:
269
+ comparable_players = projections_df[(projections_df['player_names'].isin(specific_replacements)) &
270
+ (projections_df['salary'] <= comp_salary_high + (salary_max - working_frame['salary'][row]))
271
  ]
272
  else:
273
  comparable_players = projections_df[