James McCool commited on
Commit
8b34fed
·
1 Parent(s): baf515a

Add team comparison for filtering comparable players in exposure_spread.py, ensuring accurate player selection for size 5 lineups.

Browse files
Files changed (1) hide show
  1. global_func/exposure_spread.py +2 -1
global_func/exposure_spread.py CHANGED
@@ -163,6 +163,7 @@ def exposure_spread(working_frame, exposure_player, exposure_target, exposure_st
163
  # players can be eligible at multiple positions, so we need to find all the positions the player is eligible at
164
  # the position column can have positions designated as 1B/OF which means they are eligible at 1B and OF
165
  comp_player_position = comparable_players['position'].tolist()
 
166
  try:
167
  comp_player_position = [pos.split('/') for pos in comp_player_position]
168
  comp_player_position = [item for sublist in comp_player_position for item in sublist]
@@ -266,7 +267,7 @@ def exposure_spread(working_frame, exposure_player, exposure_target, exposure_st
266
  (projections_df['position'].apply(lambda x: has_position_overlap(x, comp_player_position)))
267
  ]
268
 
269
- if row['Size'] == 5:
270
  remove_mask = comparable_players.apply(
271
  lambda row: not any(team in list(row) for team in working_frame['Stack'][row]), axis=1
272
  )
 
163
  # players can be eligible at multiple positions, so we need to find all the positions the player is eligible at
164
  # the position column can have positions designated as 1B/OF which means they are eligible at 1B and OF
165
  comp_player_position = comparable_players['position'].tolist()
166
+ comp_team = comparable_players['team'].tolist()
167
  try:
168
  comp_player_position = [pos.split('/') for pos in comp_player_position]
169
  comp_player_position = [item for sublist in comp_player_position for item in sublist]
 
267
  (projections_df['position'].apply(lambda x: has_position_overlap(x, comp_player_position)))
268
  ]
269
 
270
+ if row['Size'] == 5 and comp_team != row['Stack']:
271
  remove_mask = comparable_players.apply(
272
  lambda row: not any(team in list(row) for team in working_frame['Stack'][row]), axis=1
273
  )