James McCool commited on
Commit
90fa87c
·
1 Parent(s): 45bb52c

Refactor custom export options in app.py: reorganize layout to separate buttons for adding all and selected rows to the custom export, improving user interface clarity and functionality.

Browse files
Files changed (1) hide show
  1. app.py +11 -13
app.py CHANGED
@@ -1201,22 +1201,20 @@ with tab2:
1201
  st.session_state['export_file'][col] = st.session_state['export_file'][col].map(st.session_state['export_dict'])
1202
 
1203
  if 'export_file' in st.session_state:
1204
- download_port, merge_port, clear_export, blank_export_col = st.columns([1, 1, 1, 8])
1205
  with download_port:
1206
  st.download_button(label="Download Portfolio", data=st.session_state['export_file'].to_csv(index=False), file_name="portfolio.csv", mime="text/csv")
1207
  with merge_port:
1208
- add_all_col, add_select_col = st.columns(2)
1209
- with add_all_col:
1210
- if st.button("Add all to Custom Export"):
1211
- st.session_state['export_base'] = pd.concat([st.session_state['export_base'], st.session_state['export_merge']])
1212
- st.session_state['export_base'] = st.session_state['export_base'].drop_duplicates()
1213
- st.session_state['export_base'] = st.session_state['export_base'].reset_index(drop=True)
1214
- with add_select_col:
1215
- select_custom_index = st.multiselect("Select rows to add to Custom Export", options=st.session_state['export_merge'].index, default=[])
1216
- if st.button("Add selected to Custom Export"):
1217
- st.session_state['export_base'] = pd.concat([st.session_state['export_base'], st.session_state['export_merge'].iloc[select_custom_index]])
1218
- st.session_state['export_base'] = st.session_state['export_base'].drop_duplicates()
1219
- st.session_state['export_base'] = st.session_state['export_base'].reset_index(drop=True)
1220
  with clear_export:
1221
  if st.button("Clear Custom Export"):
1222
  st.session_state['export_base'] = pd.DataFrame(columns=st.session_state['working_frame'].columns)
 
1201
  st.session_state['export_file'][col] = st.session_state['export_file'][col].map(st.session_state['export_dict'])
1202
 
1203
  if 'export_file' in st.session_state:
1204
+ download_port, merge_port, partial_col, clear_export, blank_export_col = st.columns([1, 1, 1, 8])
1205
  with download_port:
1206
  st.download_button(label="Download Portfolio", data=st.session_state['export_file'].to_csv(index=False), file_name="portfolio.csv", mime="text/csv")
1207
  with merge_port:
1208
+ if st.button("Add all to Custom Export"):
1209
+ st.session_state['export_base'] = pd.concat([st.session_state['export_base'], st.session_state['export_merge']])
1210
+ st.session_state['export_base'] = st.session_state['export_base'].drop_duplicates()
1211
+ st.session_state['export_base'] = st.session_state['export_base'].reset_index(drop=True)
1212
+ with partial_col:
1213
+ select_custom_index = st.multiselect("Select rows to add to Custom Export", options=st.session_state['export_merge'].index, default=[])
1214
+ if st.button("Add selected to Custom Export"):
1215
+ st.session_state['export_base'] = pd.concat([st.session_state['export_base'], st.session_state['export_merge'].iloc[select_custom_index]])
1216
+ st.session_state['export_base'] = st.session_state['export_base'].drop_duplicates()
1217
+ st.session_state['export_base'] = st.session_state['export_base'].reset_index(drop=True)
 
 
1218
  with clear_export:
1219
  if st.button("Clear Custom Export"):
1220
  st.session_state['export_base'] = pd.DataFrame(columns=st.session_state['working_frame'].columns)