James McCool
commited on
Commit
·
6fbfae9
1
Parent(s):
4ed60b8
Refactor player iteration logic in hedging_preset.py to improve clarity and accuracy in lineup filtering. Changed variable names for consistency and adjusted mask conditions to enhance player selection criteria.
Browse files
global_func/hedging_preset.py
CHANGED
|
@@ -14,18 +14,18 @@ def hedging_preset(portfolio: pd.DataFrame, lineup_target: int, projections_file
|
|
| 14 |
|
| 15 |
concat_portfolio = pd.DataFrame(columns=portfolio.columns)
|
| 16 |
|
| 17 |
-
for
|
| 18 |
-
print(
|
| 19 |
working_df = portfolio.copy()
|
| 20 |
|
| 21 |
# Create mask for lineups that contain any of the removed players
|
| 22 |
player_columns = [col for col in working_df.columns if col not in excluded_cols]
|
| 23 |
|
| 24 |
remove_mask = working_df[player_columns].apply(
|
| 25 |
-
lambda row: not
|
| 26 |
)
|
| 27 |
lock_mask = working_df[player_columns].apply(
|
| 28 |
-
lambda row:
|
| 29 |
)
|
| 30 |
|
| 31 |
removed_df = working_df[remove_mask]
|
|
|
|
| 14 |
|
| 15 |
concat_portfolio = pd.DataFrame(columns=portfolio.columns)
|
| 16 |
|
| 17 |
+
for player in top_owned:
|
| 18 |
+
print(player)
|
| 19 |
working_df = portfolio.copy()
|
| 20 |
|
| 21 |
# Create mask for lineups that contain any of the removed players
|
| 22 |
player_columns = [col for col in working_df.columns if col not in excluded_cols]
|
| 23 |
|
| 24 |
remove_mask = working_df[player_columns].apply(
|
| 25 |
+
lambda row: player not in list(row), axis=1
|
| 26 |
)
|
| 27 |
lock_mask = working_df[player_columns].apply(
|
| 28 |
+
lambda row: player in list(row), axis=1
|
| 29 |
)
|
| 30 |
|
| 31 |
removed_df = working_df[remove_mask]
|