James McCool
commited on
Commit
·
da65172
1
Parent(s):
a281a4f
Refactor player filtering logic in 'Manage Portfolio' to streamline beta condition application, ensuring it only processes rows that meet the alpha condition, enhancing efficiency in lineup management.
Browse files
app.py
CHANGED
@@ -1486,6 +1486,9 @@ if selected_tab == 'Manage Portfolio':
|
|
1486 |
player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
|
1487 |
alpha_mask = alpha_mask & player_present
|
1488 |
|
|
|
|
|
|
|
1489 |
# For rows that match alpha condition, check beta condition
|
1490 |
if conditional_var == 'Any':
|
1491 |
# Check if row contains ANY of the beta players
|
@@ -1507,11 +1510,11 @@ if selected_tab == 'Manage Portfolio':
|
|
1507 |
beta_mask = beta_mask & (~player_present)
|
1508 |
|
1509 |
# Combine conditions: alpha_mask AND beta_mask
|
1510 |
-
final_condition =
|
1511 |
|
1512 |
# Apply keep or remove logic
|
1513 |
if keep_remove_var == 'Keep':
|
1514 |
-
parsed_frame = parsed_frame[final_condition]
|
1515 |
else: # Remove
|
1516 |
parsed_frame = parsed_frame[~final_condition]
|
1517 |
|
@@ -1540,6 +1543,9 @@ if selected_tab == 'Manage Portfolio':
|
|
1540 |
player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
|
1541 |
alpha_mask = alpha_mask & player_present
|
1542 |
|
|
|
|
|
|
|
1543 |
if conditional_var == 'Any':
|
1544 |
beta_mask = pd.Series([False] * len(parsed_frame), index=parsed_frame.index)
|
1545 |
for player in conditional_side_beta:
|
@@ -1556,10 +1562,10 @@ if selected_tab == 'Manage Portfolio':
|
|
1556 |
player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
|
1557 |
beta_mask = beta_mask & (~player_present)
|
1558 |
|
1559 |
-
final_condition =
|
1560 |
|
1561 |
if keep_remove_var == 'Keep':
|
1562 |
-
parsed_frame = parsed_frame[final_condition]
|
1563 |
else:
|
1564 |
parsed_frame = parsed_frame[~final_condition]
|
1565 |
|
|
|
1486 |
player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
|
1487 |
alpha_mask = alpha_mask & player_present
|
1488 |
|
1489 |
+
# Only apply beta logic to rows that match alpha condition
|
1490 |
+
rows_to_process = alpha_mask
|
1491 |
+
|
1492 |
# For rows that match alpha condition, check beta condition
|
1493 |
if conditional_var == 'Any':
|
1494 |
# Check if row contains ANY of the beta players
|
|
|
1510 |
beta_mask = beta_mask & (~player_present)
|
1511 |
|
1512 |
# Combine conditions: alpha_mask AND beta_mask
|
1513 |
+
final_condition = rows_to_process & beta_mask
|
1514 |
|
1515 |
# Apply keep or remove logic
|
1516 |
if keep_remove_var == 'Keep':
|
1517 |
+
parsed_frame = parsed_frame[~rows_to_process | final_condition]
|
1518 |
else: # Remove
|
1519 |
parsed_frame = parsed_frame[~final_condition]
|
1520 |
|
|
|
1543 |
player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
|
1544 |
alpha_mask = alpha_mask & player_present
|
1545 |
|
1546 |
+
# Only apply beta logic to rows that match alpha condition
|
1547 |
+
rows_to_process = alpha_mask
|
1548 |
+
|
1549 |
if conditional_var == 'Any':
|
1550 |
beta_mask = pd.Series([False] * len(parsed_frame), index=parsed_frame.index)
|
1551 |
for player in conditional_side_beta:
|
|
|
1562 |
player_present = parsed_frame.apply(lambda row: player in row.values, axis=1)
|
1563 |
beta_mask = beta_mask & (~player_present)
|
1564 |
|
1565 |
+
final_condition = rows_to_process & beta_mask
|
1566 |
|
1567 |
if keep_remove_var == 'Keep':
|
1568 |
+
parsed_frame = parsed_frame[~rows_to_process | final_condition]
|
1569 |
else:
|
1570 |
parsed_frame = parsed_frame[~final_condition]
|
1571 |
|