James McCool
commited on
Commit
·
b3c964e
1
Parent(s):
20a3bf0
Refactor trimming logic in app.py: streamline the portfolio trimming process by creating a copy of the working_frame before applying the trim function, and restore the display frame selection functionality for improved user experience.
Browse files
app.py
CHANGED
|
@@ -995,17 +995,9 @@ with tab2:
|
|
| 995 |
submitted = st.form_submit_button("Trim")
|
| 996 |
if submitted:
|
| 997 |
st.write('initiated')
|
| 998 |
-
|
| 999 |
-
if 'trimming_dict_maxes' not in st.session_state:
|
| 1000 |
-
st.session_state['trimming_dict_maxes'] = {
|
| 1001 |
-
'Own': st.session_state['working_frame']['Own'].max(),
|
| 1002 |
-
'Geomean': st.session_state['working_frame']['Geomean'].max(),
|
| 1003 |
-
'Weighted Own': st.session_state['working_frame']['Weighted Own'].max(),
|
| 1004 |
-
'median': st.session_state['working_frame']['median'].max(),
|
| 1005 |
-
'Finish_percentile': st.session_state['working_frame']['Finish_percentile'].max()
|
| 1006 |
-
}
|
| 1007 |
|
| 1008 |
-
st.session_state['working_frame'] = trim_portfolio(
|
| 1009 |
st.session_state['working_frame'] = st.session_state['working_frame'].sort_values(by='median', ascending=False)
|
| 1010 |
st.session_state['export_merge'] = st.session_state['working_frame'].copy()
|
| 1011 |
|
|
@@ -1092,17 +1084,16 @@ with tab2:
|
|
| 1092 |
with download_port:
|
| 1093 |
st.download_button(label="Download Portfolio", data=st.session_state['export_file'].to_csv(index=False), file_name="portfolio.csv", mime="text/csv")
|
| 1094 |
with merge_port:
|
| 1095 |
-
st.info("Working on this, ignore for now")
|
| 1096 |
if st.button("Add to export"):
|
| 1097 |
st.session_state['export_base'] = pd.concat([st.session_state['export_base'], st.session_state['export_merge']])
|
| 1098 |
else:
|
| 1099 |
st.error("No portfolio to download")
|
| 1100 |
|
| 1101 |
-
|
| 1102 |
-
|
| 1103 |
-
|
| 1104 |
-
|
| 1105 |
-
|
| 1106 |
display_frame = st.session_state['working_frame']
|
| 1107 |
total_rows = len(display_frame)
|
| 1108 |
rows_per_page = 500
|
|
|
|
| 995 |
submitted = st.form_submit_button("Trim")
|
| 996 |
if submitted:
|
| 997 |
st.write('initiated')
|
| 998 |
+
parsed_frame = st.session_state['working_frame'].copy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 999 |
|
| 1000 |
+
st.session_state['working_frame'] = trim_portfolio(parsed_frame, trim_slack_var, performance_type, own_type, performance_threshold_high, performance_threshold_low, own_threshold_high, own_threshold_low)
|
| 1001 |
st.session_state['working_frame'] = st.session_state['working_frame'].sort_values(by='median', ascending=False)
|
| 1002 |
st.session_state['export_merge'] = st.session_state['working_frame'].copy()
|
| 1003 |
|
|
|
|
| 1084 |
with download_port:
|
| 1085 |
st.download_button(label="Download Portfolio", data=st.session_state['export_file'].to_csv(index=False), file_name="portfolio.csv", mime="text/csv")
|
| 1086 |
with merge_port:
|
|
|
|
| 1087 |
if st.button("Add to export"):
|
| 1088 |
st.session_state['export_base'] = pd.concat([st.session_state['export_base'], st.session_state['export_merge']])
|
| 1089 |
else:
|
| 1090 |
st.error("No portfolio to download")
|
| 1091 |
|
| 1092 |
+
display_frame_source = st.selectbox("Display:", options=['Portfolio', 'Export Base'], key='display_frame_source')
|
| 1093 |
+
if display_frame_source == 'Portfolio':
|
| 1094 |
+
display_frame = st.session_state['working_frame']
|
| 1095 |
+
elif display_frame_source == 'Export Base':
|
| 1096 |
+
display_frame = st.session_state['export_base']
|
| 1097 |
display_frame = st.session_state['working_frame']
|
| 1098 |
total_rows = len(display_frame)
|
| 1099 |
rows_per_page = 500
|