James McCool
commited on
Commit
·
bbf380a
1
Parent(s):
fc490c5
Add user interface enhancements in app.py: introduce new selection options for site, sport, game type, contest size, and field strength, along with a clear data reset button, improving user experience and interaction within the application.
Browse files
app.py
CHANGED
|
@@ -22,9 +22,27 @@ from global_func.trim_portfolio import trim_portfolio
|
|
| 22 |
from global_func.get_portfolio_names import get_portfolio_names
|
| 23 |
|
| 24 |
freq_format = {'Finish_percentile': '{:.2%}', 'Lineup Edge': '{:.2%}', 'Win%': '{:.2%}'}
|
|
|
|
| 25 |
player_wrong_names_mlb = ['Enrique Hernandez']
|
| 26 |
player_right_names_mlb = ['Kike Hernandez']
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
tab1, tab2 = st.tabs(["Data Load", "Manage Portfolio"])
|
| 29 |
with tab1:
|
| 30 |
if st.button('Clear data', key='reset1'):
|
|
@@ -231,7 +249,7 @@ with tab1:
|
|
| 231 |
projections['player_names'] = projections['player_names'].map(lambda x: projections_match_dict.get(x, x))
|
| 232 |
st.session_state['projections_df'] = projections
|
| 233 |
|
| 234 |
-
if 'Stack' not in st.session_state['portfolio'].columns:
|
| 235 |
team_dict = dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['team']))
|
| 236 |
st.session_state['portfolio']['Stack'] = st.session_state['portfolio'].apply(
|
| 237 |
lambda row: Counter(
|
|
@@ -763,27 +781,10 @@ with tab1:
|
|
| 763 |
|
| 764 |
with tab2:
|
| 765 |
if 'portfolio' in st.session_state and 'projections_df' in st.session_state:
|
| 766 |
-
|
|
|
|
| 767 |
|
| 768 |
excluded_cols = ['salary', 'median', 'Own', 'Finish_percentile', 'Dupes', 'Stack', 'Win%', 'Lineup Edge', 'Weighted Own', 'Geomean']
|
| 769 |
-
with st.container():
|
| 770 |
-
|
| 771 |
-
col1, col2, col3 = st.columns(3)
|
| 772 |
-
with col1:
|
| 773 |
-
site_var = st.selectbox("Select Site", ['Draftkings', 'Fanduel'])
|
| 774 |
-
if st.button('Reset Portfolio', key='reset_port'):
|
| 775 |
-
del st.session_state['working_frame']
|
| 776 |
-
|
| 777 |
-
if st.button('Clear data', key='reset3'):
|
| 778 |
-
st.session_state.clear()
|
| 779 |
-
|
| 780 |
-
with col2:
|
| 781 |
-
sport_var = st.selectbox("Select Sport", ['NFL', 'MLB', 'NBA', 'NHL', 'MMA', 'CS2'])
|
| 782 |
-
type_var = st.selectbox("Select Game Type", ['Classic', 'Showdown'])
|
| 783 |
-
|
| 784 |
-
with col3:
|
| 785 |
-
Contest_Size = st.number_input("Enter Contest Size", value=25000, min_value=1, step=1)
|
| 786 |
-
strength_var = st.selectbox("Select field strength", ['Average', 'Sharp', 'Weak'])
|
| 787 |
|
| 788 |
if 'working_frame' not in st.session_state:
|
| 789 |
st.session_state['working_frame'] = st.session_state['origin_portfolio'].copy()
|
|
|
|
| 22 |
from global_func.get_portfolio_names import get_portfolio_names
|
| 23 |
|
| 24 |
freq_format = {'Finish_percentile': '{:.2%}', 'Lineup Edge': '{:.2%}', 'Win%': '{:.2%}'}
|
| 25 |
+
stacking_sports = ['MLB', 'NHL', 'NFL']
|
| 26 |
player_wrong_names_mlb = ['Enrique Hernandez']
|
| 27 |
player_right_names_mlb = ['Kike Hernandez']
|
| 28 |
|
| 29 |
+
with st.container():
|
| 30 |
+
|
| 31 |
+
col1, col2, col3 = st.columns(3)
|
| 32 |
+
with col1:
|
| 33 |
+
site_var = st.selectbox("Select Site", ['Draftkings', 'Fanduel'])
|
| 34 |
+
|
| 35 |
+
if st.button('Clear data', key='reset3'):
|
| 36 |
+
st.session_state.clear()
|
| 37 |
+
|
| 38 |
+
with col2:
|
| 39 |
+
sport_var = st.selectbox("Select Sport", ['NFL', 'MLB', 'NBA', 'NHL', 'MMA', 'CS2', 'TENNIS', 'GOLF'])
|
| 40 |
+
type_var = st.selectbox("Select Game Type", ['Classic', 'Showdown'])
|
| 41 |
+
|
| 42 |
+
with col3:
|
| 43 |
+
Contest_Size = st.number_input("Enter Contest Size", value=25000, min_value=1, step=1)
|
| 44 |
+
strength_var = st.selectbox("Select field strength", ['Average', 'Sharp', 'Weak'])
|
| 45 |
+
|
| 46 |
tab1, tab2 = st.tabs(["Data Load", "Manage Portfolio"])
|
| 47 |
with tab1:
|
| 48 |
if st.button('Clear data', key='reset1'):
|
|
|
|
| 249 |
projections['player_names'] = projections['player_names'].map(lambda x: projections_match_dict.get(x, x))
|
| 250 |
st.session_state['projections_df'] = projections
|
| 251 |
|
| 252 |
+
if 'Stack' not in st.session_state['portfolio'].columns and sport_var in stacking_sports:
|
| 253 |
team_dict = dict(zip(st.session_state['projections_df']['player_names'], st.session_state['projections_df']['team']))
|
| 254 |
st.session_state['portfolio']['Stack'] = st.session_state['portfolio'].apply(
|
| 255 |
lambda row: Counter(
|
|
|
|
| 781 |
|
| 782 |
with tab2:
|
| 783 |
if 'portfolio' in st.session_state and 'projections_df' in st.session_state:
|
| 784 |
+
if st.button('Reset Portfolio', key='reset_port'):
|
| 785 |
+
del st.session_state['working_frame']
|
| 786 |
|
| 787 |
excluded_cols = ['salary', 'median', 'Own', 'Finish_percentile', 'Dupes', 'Stack', 'Win%', 'Lineup Edge', 'Weighted Own', 'Geomean']
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 788 |
|
| 789 |
if 'working_frame' not in st.session_state:
|
| 790 |
st.session_state['working_frame'] = st.session_state['origin_portfolio'].copy()
|