James McCool
commited on
Commit
·
45bb52c
1
Parent(s):
cadc1d7
Add custom export functionality in app.py: introduce options to add all or selected rows from the merge DataFrame to the custom export, enhancing user control over data selection and improving export flexibility.
Browse files
app.py
CHANGED
@@ -1205,10 +1205,18 @@ with tab2:
|
|
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 |
-
|
1209 |
-
|
1210 |
-
st.
|
1211 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1212 |
with clear_export:
|
1213 |
if st.button("Clear Custom Export"):
|
1214 |
st.session_state['export_base'] = pd.DataFrame(columns=st.session_state['working_frame'].columns)
|
|
|
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)
|