James McCool
commited on
Commit
·
57ecfc8
1
Parent(s):
1afc466
Refactor Streamlit UI in app.py: reorganize layout for clearer user interaction and restore 'Clear data' button functionality.
Browse files
app.py
CHANGED
|
@@ -681,18 +681,25 @@ with tab2:
|
|
| 681 |
)
|
| 682 |
|
| 683 |
with tab3:
|
| 684 |
-
if st.button('Clear data', key='reset3'):
|
| 685 |
-
st.session_state.clear()
|
| 686 |
if 'portfolio' in st.session_state and 'projections_df' in st.session_state:
|
| 687 |
-
|
| 688 |
excluded_cols = ['salary', 'median', 'Own', 'Finish_percentile', 'Dupes', 'Stack', 'Win%', 'Lineup Edge']
|
| 689 |
-
with
|
| 690 |
-
|
| 691 |
-
|
| 692 |
-
|
| 693 |
-
|
| 694 |
-
|
| 695 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 696 |
if site_var == 'Draftkings':
|
| 697 |
if type_var == 'Classic':
|
| 698 |
map_dict = {
|
|
@@ -771,7 +778,9 @@ with tab3:
|
|
| 771 |
sum(map_dict['own_map'].get(player, 0) for player in row.iloc[1:]),
|
| 772 |
axis=1
|
| 773 |
)
|
| 774 |
-
|
|
|
|
|
|
|
| 775 |
with st.form(key='filter_form'):
|
| 776 |
max_dupes = st.number_input("Max acceptable dupes?", value=1000, min_value=1, step=1)
|
| 777 |
min_salary = st.number_input("Min acceptable salary?", value=1000, min_value=1000, step=100)
|
|
@@ -790,7 +799,7 @@ with tab3:
|
|
| 790 |
|
| 791 |
submitted = st.form_submit_button("Submit")
|
| 792 |
|
| 793 |
-
with
|
| 794 |
st.session_state['portfolio'] = predict_dupes(st.session_state['portfolio'], map_dict, site_var, type_var, Contest_Size, strength_var)
|
| 795 |
st.session_state['portfolio'] = st.session_state['portfolio'][st.session_state['portfolio']['Dupes'] <= max_dupes]
|
| 796 |
st.session_state['portfolio'] = st.session_state['portfolio'][st.session_state['portfolio']['salary'] >= min_salary]
|
|
|
|
| 681 |
)
|
| 682 |
|
| 683 |
with tab3:
|
|
|
|
|
|
|
| 684 |
if 'portfolio' in st.session_state and 'projections_df' in st.session_state:
|
| 685 |
+
|
| 686 |
excluded_cols = ['salary', 'median', 'Own', 'Finish_percentile', 'Dupes', 'Stack', 'Win%', 'Lineup Edge']
|
| 687 |
+
with st.container():
|
| 688 |
+
col1, col2, col3 = st.columns(3)
|
| 689 |
+
with col1:
|
| 690 |
+
if st.button('Clear data', key='reset3'):
|
| 691 |
+
st.session_state.clear()
|
| 692 |
+
site_var = st.selectbox("Select Site", ['Draftkings', 'Fanduel'])
|
| 693 |
+
|
| 694 |
+
with col2:
|
| 695 |
+
sport_var = st.selectbox("Select Sport", ['NFL', 'MLB', 'NBA', 'NHL', 'MMA'])
|
| 696 |
+
st.info("It currently does not matter what sport you select, it may matter in the future.")
|
| 697 |
+
type_var = st.selectbox("Select Game Type", ['Classic', 'Showdown'])
|
| 698 |
+
|
| 699 |
+
with col3:
|
| 700 |
+
Contest_Size = st.number_input("Enter Contest Size", value=25000, min_value=1, step=1)
|
| 701 |
+
strength_var = st.selectbox("Select field strength", ['Average', 'Sharp', 'Weak'])
|
| 702 |
+
|
| 703 |
if site_var == 'Draftkings':
|
| 704 |
if type_var == 'Classic':
|
| 705 |
map_dict = {
|
|
|
|
| 778 |
sum(map_dict['own_map'].get(player, 0) for player in row.iloc[1:]),
|
| 779 |
axis=1
|
| 780 |
)
|
| 781 |
+
|
| 782 |
+
col1, col2 = st.columns([9, 1])
|
| 783 |
+
with col2:
|
| 784 |
with st.form(key='filter_form'):
|
| 785 |
max_dupes = st.number_input("Max acceptable dupes?", value=1000, min_value=1, step=1)
|
| 786 |
min_salary = st.number_input("Min acceptable salary?", value=1000, min_value=1000, step=100)
|
|
|
|
| 799 |
|
| 800 |
submitted = st.form_submit_button("Submit")
|
| 801 |
|
| 802 |
+
with col1:
|
| 803 |
st.session_state['portfolio'] = predict_dupes(st.session_state['portfolio'], map_dict, site_var, type_var, Contest_Size, strength_var)
|
| 804 |
st.session_state['portfolio'] = st.session_state['portfolio'][st.session_state['portfolio']['Dupes'] <= max_dupes]
|
| 805 |
st.session_state['portfolio'] = st.session_state['portfolio'][st.session_state['portfolio']['salary'] >= min_salary]
|