James McCool
commited on
Commit
·
a6f8dd9
1
Parent(s):
547e62e
Adding base choice functionality? Or at least trying to
Browse files
app.py
CHANGED
|
@@ -1745,15 +1745,23 @@ if selected_tab == 'Manage Portfolio':
|
|
| 1745 |
with st.container():
|
| 1746 |
reset_port_col, recalc_div_col, set_base_col, blank_reset_col, contest_size_col = st.columns([1, 1, 1, 6, 4])
|
| 1747 |
with reset_port_col:
|
| 1748 |
-
|
| 1749 |
-
st.
|
| 1750 |
-
st.
|
|
|
|
| 1751 |
with recalc_div_col:
|
| 1752 |
if st.button("Recalculate Diversity"):
|
| 1753 |
st.session_state['display_frame']['Diversity'] = recalc_diversity(st.session_state['display_frame'], st.session_state['player_columns'])
|
| 1754 |
with set_base_col:
|
| 1755 |
-
|
| 1756 |
-
st.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1757 |
|
| 1758 |
with contest_size_col:
|
| 1759 |
with st.form(key='contest_size_form'):
|
|
@@ -1792,7 +1800,8 @@ if selected_tab == 'Manage Portfolio':
|
|
| 1792 |
st.session_state['working_frame']['Size'] = st.session_state['working_frame'].index.map(st.session_state['size_dict'])
|
| 1793 |
|
| 1794 |
st.session_state['base_frame'] = predict_dupes(st.session_state['working_frame'], st.session_state['map_dict'], site_var, type_var, Contest_Size, strength_var, sport_var, salary_max)
|
| 1795 |
-
st.session_state['
|
|
|
|
| 1796 |
# st.session_state['highest_owned_teams'] = st.session_state['projections_df'][~st.session_state['projections_df']['position'].isin(['P', 'SP'])].groupby('team')['ownership'].sum().sort_values(ascending=False).head(3).index.tolist()
|
| 1797 |
# st.session_state['highest_owned_pitchers'] = st.session_state['projections_df'][st.session_state['projections_df']['position'].isin(['P', 'SP'])]['player_names'].sort_values(by='ownership', ascending=False).head(3).tolist()
|
| 1798 |
|
|
|
|
| 1745 |
with st.container():
|
| 1746 |
reset_port_col, recalc_div_col, set_base_col, blank_reset_col, contest_size_col = st.columns([1, 1, 1, 6, 4])
|
| 1747 |
with reset_port_col:
|
| 1748 |
+
with st.popover("Reset Portfolio"):
|
| 1749 |
+
st.markdown("choose a base to reset to:")
|
| 1750 |
+
base_choice = st.selectbox("Base Choice", options=st.session_state['base_frame_names'], index=0)
|
| 1751 |
+
st.session_state['working_frame'] = st.session_state[f'{base_choice}']
|
| 1752 |
with recalc_div_col:
|
| 1753 |
if st.button("Recalculate Diversity"):
|
| 1754 |
st.session_state['display_frame']['Diversity'] = recalc_diversity(st.session_state['display_frame'], st.session_state['player_columns'])
|
| 1755 |
with set_base_col:
|
| 1756 |
+
with st.popover("New Base Setting"):
|
| 1757 |
+
st.markdown("Name of new base:")
|
| 1758 |
+
new_base_name = st.text_input("New Base Name", value='New Base')
|
| 1759 |
+
if f'{new_base_name}' not in st.session_state['base_frame_names']:
|
| 1760 |
+
st.session_state['base_frame_names'].append(f'{new_base_name}')
|
| 1761 |
+
st.session_state['base_frame_names'] = sorted(st.session_state['base_frame_names'])
|
| 1762 |
+
st.session_state[f'{new_base_name}'] = st.session_state['working_frame']
|
| 1763 |
+
else:
|
| 1764 |
+
st.error("Base name already exists")
|
| 1765 |
|
| 1766 |
with contest_size_col:
|
| 1767 |
with st.form(key='contest_size_form'):
|
|
|
|
| 1800 |
st.session_state['working_frame']['Size'] = st.session_state['working_frame'].index.map(st.session_state['size_dict'])
|
| 1801 |
|
| 1802 |
st.session_state['base_frame'] = predict_dupes(st.session_state['working_frame'], st.session_state['map_dict'], site_var, type_var, Contest_Size, strength_var, sport_var, salary_max)
|
| 1803 |
+
st.session_state[f'{base_choice}'] = st.session_state['base_frame']
|
| 1804 |
+
st.session_state['working_frame'] = st.session_state['base_frame']
|
| 1805 |
# st.session_state['highest_owned_teams'] = st.session_state['projections_df'][~st.session_state['projections_df']['position'].isin(['P', 'SP'])].groupby('team')['ownership'].sum().sort_values(ascending=False).head(3).index.tolist()
|
| 1806 |
# st.session_state['highest_owned_pitchers'] = st.session_state['projections_df'][st.session_state['projections_df']['position'].isin(['P', 'SP'])]['player_names'].sort_values(by='ownership', ascending=False).head(3).tolist()
|
| 1807 |
|