James McCool
commited on
Commit
·
42199ca
1
Parent(s):
22483d5
Limit concatenation in distribute_preset function to the top 10 entries of the working portfolio, removing debug print statements for cleaner output and improved performance in portfolio processing.
Browse files
global_func/distribute_preset.py
CHANGED
|
@@ -19,9 +19,6 @@ def distribute_preset(portfolio: pd.DataFrame, lineup_target: int, exclude_cols:
|
|
| 19 |
working_portfolio = working_portfolio[working_portfolio['Finish_percentile'] >= lower_threshold]
|
| 20 |
working_portfolio = working_portfolio.sort_values(by='median', ascending = False)
|
| 21 |
working_portfolio = working_portfolio.reset_index(drop=True)
|
| 22 |
-
print(finish_threshold)
|
| 23 |
-
print(lower_threshold)
|
| 24 |
-
print(working_portfolio[['Finish_percentile', 'Weighted Own']].sort_values(by='Finish_percentile', ascending=True).head(10))
|
| 25 |
if len(working_portfolio) == 0:
|
| 26 |
continue
|
| 27 |
elif len(working_portfolio) >= 1:
|
|
@@ -34,7 +31,7 @@ def distribute_preset(portfolio: pd.DataFrame, lineup_target: int, exclude_cols:
|
|
| 34 |
curr_own_type_max = working_portfolio.loc[i, 'Weighted Own'] + (slack_var / 20 * working_portfolio.loc[i, 'Weighted Own'])
|
| 35 |
|
| 36 |
working_portfolio = working_portfolio.drop(rows_to_drop).reset_index(drop=True)
|
| 37 |
-
concat_portfolio = pd.concat([concat_portfolio, working_portfolio])
|
| 38 |
|
| 39 |
if len(concat_portfolio) >= lineup_target:
|
| 40 |
return concat_portfolio.sort_values(by='Finish_percentile', ascending=True).head(lineup_target)
|
|
|
|
| 19 |
working_portfolio = working_portfolio[working_portfolio['Finish_percentile'] >= lower_threshold]
|
| 20 |
working_portfolio = working_portfolio.sort_values(by='median', ascending = False)
|
| 21 |
working_portfolio = working_portfolio.reset_index(drop=True)
|
|
|
|
|
|
|
|
|
|
| 22 |
if len(working_portfolio) == 0:
|
| 23 |
continue
|
| 24 |
elif len(working_portfolio) >= 1:
|
|
|
|
| 31 |
curr_own_type_max = working_portfolio.loc[i, 'Weighted Own'] + (slack_var / 20 * working_portfolio.loc[i, 'Weighted Own'])
|
| 32 |
|
| 33 |
working_portfolio = working_portfolio.drop(rows_to_drop).reset_index(drop=True)
|
| 34 |
+
concat_portfolio = pd.concat([concat_portfolio, working_portfolio.head(10)])
|
| 35 |
|
| 36 |
if len(concat_portfolio) >= lineup_target:
|
| 37 |
return concat_portfolio.sort_values(by='Finish_percentile', ascending=True).head(lineup_target)
|