James McCool
commited on
Commit
·
a6d3a93
1
Parent(s):
cd18aa9
Refactor small_field_preset function to ensure consistent DataFrame structure by resetting the index after filtering and sorting the working portfolio by Median before returning results, improving accuracy in lineup selection.
Browse files- app.py +1 -1
- global_func/small_field_preset.py +4 -3
app.py
CHANGED
@@ -1115,7 +1115,7 @@ with tab2:
|
|
1115 |
# parsed_frame = volatile_preset(st.session_state['working_frame'], lineup_target)
|
1116 |
# elif preset_choice == 'Distributed':
|
1117 |
# parsed_frame = distributed_preset(st.session_state['working_frame'], lineup_target)
|
1118 |
-
st.session_state['working_frame'] = parsed_frame.
|
1119 |
st.session_state['export_merge'] = st.session_state['working_frame'].copy()
|
1120 |
|
1121 |
with col2:
|
|
|
1115 |
# parsed_frame = volatile_preset(st.session_state['working_frame'], lineup_target)
|
1116 |
# elif preset_choice == 'Distributed':
|
1117 |
# parsed_frame = distributed_preset(st.session_state['working_frame'], lineup_target)
|
1118 |
+
st.session_state['working_frame'] = parsed_frame.reset_index(drop=True)
|
1119 |
st.session_state['export_merge'] = st.session_state['working_frame'].copy()
|
1120 |
|
1121 |
with col2:
|
global_func/small_field_preset.py
CHANGED
@@ -5,7 +5,8 @@ def small_field_preset(portfolio: pd.DataFrame, lineup_target: int):
|
|
5 |
for slack_var in range(1, 10):
|
6 |
rows_to_drop = []
|
7 |
working_portfolio = portfolio.sort_values(by='Own', ascending = False).reset_index(drop=True)
|
8 |
-
working_portfolio = working_portfolio[working_portfolio['Finish_percentile'] <= .10]
|
|
|
9 |
curr_own_type_max = working_portfolio.loc[0, 'Weighted Own'] + (slack_var / 10 * working_portfolio.loc[0, 'Weighted Own'])
|
10 |
|
11 |
for i in range(1, len(working_portfolio)):
|
@@ -16,6 +17,6 @@ def small_field_preset(portfolio: pd.DataFrame, lineup_target: int):
|
|
16 |
|
17 |
working_portfolio = working_portfolio.drop(rows_to_drop).reset_index(drop=True)
|
18 |
if len(working_portfolio) >= lineup_target:
|
19 |
-
return working_portfolio.head(lineup_target)
|
20 |
|
21 |
-
return working_portfolio
|
|
|
5 |
for slack_var in range(1, 10):
|
6 |
rows_to_drop = []
|
7 |
working_portfolio = portfolio.sort_values(by='Own', ascending = False).reset_index(drop=True)
|
8 |
+
working_portfolio = working_portfolio[working_portfolio['Finish_percentile'] <= .10]
|
9 |
+
working_portfolio = working_portfolio.reset_index(drop=True)
|
10 |
curr_own_type_max = working_portfolio.loc[0, 'Weighted Own'] + (slack_var / 10 * working_portfolio.loc[0, 'Weighted Own'])
|
11 |
|
12 |
for i in range(1, len(working_portfolio)):
|
|
|
17 |
|
18 |
working_portfolio = working_portfolio.drop(rows_to_drop).reset_index(drop=True)
|
19 |
if len(working_portfolio) >= lineup_target:
|
20 |
+
return working_portfolio.sort_values(by='Median', ascending=False).head(lineup_target)
|
21 |
|
22 |
+
return working_portfolio.sort_values(by='Median', ascending=False)
|