James McCool
commited on
Commit
·
298e2c8
1
Parent(s):
2344dbb
Refactor 'exposure_spread' function to support specific column selections for player data retrieval, enhancing flexibility in player filtering logic.
Browse files
global_func/exposure_spread.py
CHANGED
|
@@ -248,7 +248,10 @@ def exposure_spread(working_frame, exposure_player, exposure_target, ignore_stac
|
|
| 248 |
comparable_players = comparable_players[remove_mask]
|
| 249 |
|
| 250 |
# Get the current row data to check for existing players
|
| 251 |
-
|
|
|
|
|
|
|
|
|
|
| 252 |
|
| 253 |
# Filter out players that are already present in this row
|
| 254 |
existing_players = set(current_row_data.values)
|
|
@@ -264,8 +267,15 @@ def exposure_spread(working_frame, exposure_player, exposure_target, ignore_stac
|
|
| 264 |
if comparable_player_list:
|
| 265 |
insert_player = random.choice(comparable_player_list)
|
| 266 |
# Find which column contains the exposure_player
|
| 267 |
-
|
| 268 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 269 |
if row_data[col] == exposure_player:
|
| 270 |
# Get the replacement player's positions
|
| 271 |
replacement_player_positions = projections_df[projections_df['player_names'] == insert_player]['position'].iloc[0].split('/')
|
|
|
|
| 248 |
comparable_players = comparable_players[remove_mask]
|
| 249 |
|
| 250 |
# Get the current row data to check for existing players
|
| 251 |
+
if specific_columns != []:
|
| 252 |
+
current_row_data = working_frame.iloc[row][specific_columns]
|
| 253 |
+
else:
|
| 254 |
+
current_row_data = working_frame.iloc[row]
|
| 255 |
|
| 256 |
# Filter out players that are already present in this row
|
| 257 |
existing_players = set(current_row_data.values)
|
|
|
|
| 267 |
if comparable_player_list:
|
| 268 |
insert_player = random.choice(comparable_player_list)
|
| 269 |
# Find which column contains the exposure_player
|
| 270 |
+
if specific_columns != []:
|
| 271 |
+
row_data = working_frame.iloc[row][specific_columns]
|
| 272 |
+
working_columns = specific_columns
|
| 273 |
+
else:
|
| 274 |
+
row_data = working_frame.iloc[row]
|
| 275 |
+
working_columns = working_frame.columns
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
for col in working_columns:
|
| 279 |
if row_data[col] == exposure_player:
|
| 280 |
# Get the replacement player's positions
|
| 281 |
replacement_player_positions = projections_df[projections_df['player_names'] == insert_player]['position'].iloc[0].split('/')
|