James McCool
commited on
Commit
·
beef2ec
1
Parent(s):
dbc0343
Update portfolio concatenation logic in distribute_preset.py to limit the number of players added based on lineup target. This change improves the accuracy of the distribution process by ensuring that only a calculated subset of players is included in the final portfolio.
Browse files
global_func/distribute_preset.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
import pandas as pd
|
|
|
2 |
|
3 |
def distribute_preset(portfolio: pd.DataFrame, lineup_target: int, exclude_cols: list):
|
4 |
|
@@ -71,7 +72,7 @@ def distribute_preset(portfolio: pd.DataFrame, lineup_target: int, exclude_cols:
|
|
71 |
curr_own_type_max = working_portfolio.loc[i, 'Similarity Score'] + (slack_var / 20 * working_portfolio.loc[i, 'Similarity Score'])
|
72 |
|
73 |
working_portfolio = working_portfolio.drop(rows_to_drop).reset_index(drop=True)
|
74 |
-
concat_portfolio = pd.concat([concat_portfolio, working_portfolio])
|
75 |
|
76 |
if len(concat_portfolio) >= lineup_target:
|
77 |
return concat_portfolio.sort_values(by='median', ascending=False).head(lineup_target)
|
|
|
1 |
import pandas as pd
|
2 |
+
import math
|
3 |
|
4 |
def distribute_preset(portfolio: pd.DataFrame, lineup_target: int, exclude_cols: list):
|
5 |
|
|
|
72 |
curr_own_type_max = working_portfolio.loc[i, 'Similarity Score'] + (slack_var / 20 * working_portfolio.loc[i, 'Similarity Score'])
|
73 |
|
74 |
working_portfolio = working_portfolio.drop(rows_to_drop).reset_index(drop=True)
|
75 |
+
concat_portfolio = pd.concat([concat_portfolio, working_portfolio.head(math.ceil(lineup_target / 5))])
|
76 |
|
77 |
if len(concat_portfolio) >= lineup_target:
|
78 |
return concat_portfolio.sort_values(by='median', ascending=False).head(lineup_target)
|