James McCool
commited on
Commit
·
330dac8
1
Parent(s):
a5888d7
Enhance trimming options in app.py: add informational prompt for filtering before trimming and update portfolio copy logic to ensure correct data handling during download, improving user guidance and functionality.
Browse files- app.py +6 -2
- global_func/predict_dupes.py +1 -1
app.py
CHANGED
@@ -805,7 +805,7 @@ with tab3:
|
|
805 |
|
806 |
submitted = st.form_submit_button("Submit")
|
807 |
with st.expander('Trimming Options'):
|
808 |
-
|
809 |
with st.form(key='trim_form'):
|
810 |
performance_type = st.selectbox("Select Sorting variable", ['median', 'Finish_percentile'])
|
811 |
own_type = st.selectbox("Select trimming variable", ['Own', 'Weighted Own'])
|
@@ -845,6 +845,7 @@ with tab3:
|
|
845 |
st.session_state['portfolio'] = trim_portfolio(st.session_state['portfolio'], performance_type, own_type)
|
846 |
export_file = st.session_state['portfolio'].copy()
|
847 |
st.session_state['portfolio'] = st.session_state['portfolio'].sort_values(by='median', ascending=False)
|
|
|
848 |
|
849 |
with col2:
|
850 |
st.session_state['portfolio'] = predict_dupes(st.session_state['portfolio'], map_dict, site_var, type_var, Contest_Size, strength_var)
|
@@ -920,7 +921,10 @@ with tab3:
|
|
920 |
)
|
921 |
|
922 |
# Create a copy of the portfolio
|
923 |
-
|
|
|
|
|
|
|
924 |
|
925 |
# Create a list to store selected rows
|
926 |
selected_rows = []
|
|
|
805 |
|
806 |
submitted = st.form_submit_button("Submit")
|
807 |
with st.expander('Trimming Options'):
|
808 |
+
st.info("Make sure you filter before trimming if you want to filter, trimming before a filter will reset your portfolio")
|
809 |
with st.form(key='trim_form'):
|
810 |
performance_type = st.selectbox("Select Sorting variable", ['median', 'Finish_percentile'])
|
811 |
own_type = st.selectbox("Select trimming variable", ['Own', 'Weighted Own'])
|
|
|
845 |
st.session_state['portfolio'] = trim_portfolio(st.session_state['portfolio'], performance_type, own_type)
|
846 |
export_file = st.session_state['portfolio'].copy()
|
847 |
st.session_state['portfolio'] = st.session_state['portfolio'].sort_values(by='median', ascending=False)
|
848 |
+
st.session_state['download_portfolio'] = export_file
|
849 |
|
850 |
with col2:
|
851 |
st.session_state['portfolio'] = predict_dupes(st.session_state['portfolio'], map_dict, site_var, type_var, Contest_Size, strength_var)
|
|
|
921 |
)
|
922 |
|
923 |
# Create a copy of the portfolio
|
924 |
+
if 'download_portfolio' not in st.session_state:
|
925 |
+
portfolio_copy = st.session_state['portfolio'].copy()
|
926 |
+
else:
|
927 |
+
portfolio_copy = st.session_state['download_portfolio'].copy()
|
928 |
|
929 |
# Create a list to store selected rows
|
930 |
selected_rows = []
|
global_func/predict_dupes.py
CHANGED
@@ -181,7 +181,7 @@ def predict_dupes(portfolio, maps_dict, site_var, type_var, Contest_Size, streng
|
|
181 |
portfolio['Lineup Edge'] = portfolio['Win%'] * ((.5 - portfolio['Finish_percentile']) * (Contest_Size / 2.5))
|
182 |
portfolio['Lineup Edge'] = portfolio.apply(lambda row: row['Lineup Edge'] / (row['Dupes'] + 1) if row['Dupes'] > 0 else row['Lineup Edge'], axis=1)
|
183 |
portfolio['Lineup Edge'] = portfolio['Lineup Edge'] - portfolio['Lineup Edge'].mean()
|
184 |
-
portfolio['Weighted Own'] = portfolio['Own'] * ((portfolio[own_columns].max(axis=1) - portfolio[own_columns].min(axis=1)) / 100)
|
185 |
portfolio = portfolio.drop(columns=dup_count_columns)
|
186 |
portfolio = portfolio.drop(columns=own_columns)
|
187 |
portfolio = portfolio.drop(columns=calc_columns)
|
|
|
181 |
portfolio['Lineup Edge'] = portfolio['Win%'] * ((.5 - portfolio['Finish_percentile']) * (Contest_Size / 2.5))
|
182 |
portfolio['Lineup Edge'] = portfolio.apply(lambda row: row['Lineup Edge'] / (row['Dupes'] + 1) if row['Dupes'] > 0 else row['Lineup Edge'], axis=1)
|
183 |
portfolio['Lineup Edge'] = portfolio['Lineup Edge'] - portfolio['Lineup Edge'].mean()
|
184 |
+
portfolio['Weighted Own'] = (portfolio['Own'] * ((portfolio[own_columns].max(axis=1) - portfolio[own_columns].min(axis=1)) / 100)) * 200
|
185 |
portfolio = portfolio.drop(columns=dup_count_columns)
|
186 |
portfolio = portfolio.drop(columns=own_columns)
|
187 |
portfolio = portfolio.drop(columns=calc_columns)
|