Spaces:
Sleeping
Sleeping
James McCool
commited on
Commit
·
a589040
1
Parent(s):
add3552
Refactor 'Manage Portfolio' section in 'app.py' to improve layout and functionality by adding buttons for recalculating diversity, adding/removing rows from custom export, and adjusting column configurations for better user interaction.
Browse files
app.py
CHANGED
|
@@ -1084,13 +1084,16 @@ if selected_tab == 'Data Load':
|
|
| 1084 |
if selected_tab == 'Manage Portfolio':
|
| 1085 |
if 'origin_portfolio' in st.session_state and 'projections_df' in st.session_state:
|
| 1086 |
with st.container():
|
| 1087 |
-
|
| 1088 |
with col1:
|
| 1089 |
if st.button('Reset Portfolio', key='reset_port'):
|
| 1090 |
st.session_state['settings_base'] = True
|
| 1091 |
st.session_state['working_frame'] = st.session_state['base_frame'].copy()
|
| 1092 |
-
|
| 1093 |
with col2:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1094 |
with st.form(key='contest_size_form'):
|
| 1095 |
size_col, strength_col, submit_col = st.columns(3)
|
| 1096 |
with size_col:
|
|
@@ -1974,7 +1977,7 @@ if selected_tab == 'Manage Portfolio':
|
|
| 1974 |
st.session_state['export_file'][col] = st.session_state['export_file'][col].map(position_dict)
|
| 1975 |
|
| 1976 |
if 'export_file' in st.session_state:
|
| 1977 |
-
download_port, merge_port,
|
| 1978 |
with download_port:
|
| 1979 |
st.download_button(label="Download Portfolio", data=st.session_state['export_file'].to_csv(index=False), file_name="portfolio.csv", mime="text/csv")
|
| 1980 |
with merge_port:
|
|
@@ -1982,13 +1985,7 @@ if selected_tab == 'Manage Portfolio':
|
|
| 1982 |
st.session_state['export_base'] = pd.concat([st.session_state['export_base'], st.session_state['export_merge']])
|
| 1983 |
st.session_state['export_base'] = st.session_state['export_base'].drop_duplicates()
|
| 1984 |
st.session_state['export_base'] = st.session_state['export_base'].reset_index(drop=True)
|
| 1985 |
-
|
| 1986 |
-
if 'export_merge' in st.session_state:
|
| 1987 |
-
select_custom_index = st.multiselect("Select rows to add (based on first column):", options=st.session_state['export_merge'].index, default=[])
|
| 1988 |
-
if st.button("Add selected to Custom Export"):
|
| 1989 |
-
st.session_state['export_base'] = pd.concat([st.session_state['export_base'], st.session_state['export_merge'].loc[select_custom_index]])
|
| 1990 |
-
st.session_state['export_base'] = st.session_state['export_base'].drop_duplicates()
|
| 1991 |
-
st.session_state['export_base'] = st.session_state['export_base'].reset_index(drop=True)
|
| 1992 |
with clear_export:
|
| 1993 |
if st.button("Clear Custom Export"):
|
| 1994 |
st.session_state['export_base'] = pd.DataFrame(columns=st.session_state['working_frame'].columns)
|
|
@@ -1996,9 +1993,21 @@ if selected_tab == 'Manage Portfolio':
|
|
| 1996 |
st.session_state['display_frame'] = st.session_state['working_frame']
|
| 1997 |
elif display_frame_source == 'Export Base':
|
| 1998 |
st.session_state['display_frame'] = st.session_state['export_base']
|
| 1999 |
-
|
| 2000 |
-
|
| 2001 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2002 |
|
| 2003 |
total_rows = len(st.session_state['display_frame'])
|
| 2004 |
rows_per_page = 100
|
|
|
|
| 1084 |
if selected_tab == 'Manage Portfolio':
|
| 1085 |
if 'origin_portfolio' in st.session_state and 'projections_df' in st.session_state:
|
| 1086 |
with st.container():
|
| 1087 |
+
reset_port_col, recalc_div_col, blank_reset_col, contest_size_col = st.columns(2, 2, 4, 2)
|
| 1088 |
with col1:
|
| 1089 |
if st.button('Reset Portfolio', key='reset_port'):
|
| 1090 |
st.session_state['settings_base'] = True
|
| 1091 |
st.session_state['working_frame'] = st.session_state['base_frame'].copy()
|
|
|
|
| 1092 |
with col2:
|
| 1093 |
+
if st.button("Recalculate Diversity"):
|
| 1094 |
+
st.session_state['display_frame']['Diversity'] = recalc_diversity(st.session_state['display_frame'], st.session_state['player_columns'])
|
| 1095 |
+
|
| 1096 |
+
with col4:
|
| 1097 |
with st.form(key='contest_size_form'):
|
| 1098 |
size_col, strength_col, submit_col = st.columns(3)
|
| 1099 |
with size_col:
|
|
|
|
| 1977 |
st.session_state['export_file'][col] = st.session_state['export_file'][col].map(position_dict)
|
| 1978 |
|
| 1979 |
if 'export_file' in st.session_state:
|
| 1980 |
+
download_port, merge_port, clear_export, add_rows_col, remove_rows_col, blank_export_col = st.columns([1, 1, 1, 2, 2, 6])
|
| 1981 |
with download_port:
|
| 1982 |
st.download_button(label="Download Portfolio", data=st.session_state['export_file'].to_csv(index=False), file_name="portfolio.csv", mime="text/csv")
|
| 1983 |
with merge_port:
|
|
|
|
| 1985 |
st.session_state['export_base'] = pd.concat([st.session_state['export_base'], st.session_state['export_merge']])
|
| 1986 |
st.session_state['export_base'] = st.session_state['export_base'].drop_duplicates()
|
| 1987 |
st.session_state['export_base'] = st.session_state['export_base'].reset_index(drop=True)
|
| 1988 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1989 |
with clear_export:
|
| 1990 |
if st.button("Clear Custom Export"):
|
| 1991 |
st.session_state['export_base'] = pd.DataFrame(columns=st.session_state['working_frame'].columns)
|
|
|
|
| 1993 |
st.session_state['display_frame'] = st.session_state['working_frame']
|
| 1994 |
elif display_frame_source == 'Export Base':
|
| 1995 |
st.session_state['display_frame'] = st.session_state['export_base']
|
| 1996 |
+
|
| 1997 |
+
with add_rows_col:
|
| 1998 |
+
select_custom_index = st.multiselect("Select rows to add (based on first column):", options=st.session_state['export_merge'].index, default=[])
|
| 1999 |
+
if st.button("Add selected to Custom Export"):
|
| 2000 |
+
st.session_state['export_base'] = pd.concat([st.session_state['export_base'], st.session_state['export_merge'].loc[select_custom_index]])
|
| 2001 |
+
st.session_state['export_base'] = st.session_state['export_base'].drop_duplicates()
|
| 2002 |
+
st.session_state['export_base'] = st.session_state['export_base'].reset_index(drop=True)
|
| 2003 |
+
|
| 2004 |
+
with remove_rows_col:
|
| 2005 |
+
remove_custom_index = st.multiselect("Remove rows (based on first column):", options=st.session_state['display_frame'].index, default=[])
|
| 2006 |
+
if st.button("Remove selected from Display"):
|
| 2007 |
+
st.session_state['display_frame'] = st.session_state['display_frame'].drop(remove_custom_index)
|
| 2008 |
+
st.session_state['display_frame'] = st.session_state['display_frame'].drop_duplicates()
|
| 2009 |
+
st.session_state['display_frame'] = st.session_state['display_frame'].reset_index(drop=True)
|
| 2010 |
+
|
| 2011 |
|
| 2012 |
total_rows = len(st.session_state['display_frame'])
|
| 2013 |
rows_per_page = 100
|