James McCool commited on
Commit
53de179
·
1 Parent(s): 0aa6473

Refactor player position selection logic in app.py to simplify user experience. Removed conditional check for 'Specific' position selection, allowing direct multiselect input for positions.

Browse files
Files changed (1) hide show
  1. app.py +2 -6
app.py CHANGED
@@ -848,11 +848,7 @@ with tab4:
848
  with st.expander("Player Filters"):
849
  col1, col2 = st.columns(2)
850
  with col1:
851
- pos_var3 = st.selectbox("Which position(s) would you like to view?", ['All', 'Specific'], key='pos_var3')
852
- if pos_var3 == 'Specific':
853
- pos_select3 = st.multiselect("Select your position(s)", options=['P', 'C', '1B', '2B', '3B', 'SS', 'OF'], key='pos_select3')
854
- else:
855
- pos_select3 = None
856
  with col2:
857
  salary_var = st.number_input("Salary Max", min_value = 0, max_value = 20000, value = 20000, step = 100)
858
 
@@ -880,7 +876,7 @@ with tab4:
880
  player_select_df = handbuild_roo[['Player', 'Position', 'Team', 'Team_Total', 'Opp_Total', 'Salary', 'Median', '2x%', 'Order', 'Hand', 'Own%']].drop_duplicates(subset=['Player', 'Team']).copy()
881
 
882
  # If no teams selected, show all teams
883
- if pos_select3 is not None:
884
  position_mask_2 = handbuild_roo['Position'].apply(lambda x: any(pos in x for pos in pos_select3))
885
  player_select_df = handbuild_roo[position_mask_2][['Player', 'Position', 'Team', 'Team_Total', 'Opp_Total', 'Salary', 'Median', '2x%', 'Order', 'Hand', 'Own%']].drop_duplicates(subset=['Player', 'Team']).sort_values(by='Order', ascending=True).copy()
886
  else:
 
848
  with st.expander("Player Filters"):
849
  col1, col2 = st.columns(2)
850
  with col1:
851
+ pos_select3 = st.multiselect("Select your position(s)", options=['P', 'C', '1B', '2B', '3B', 'SS', 'OF'], key='pos_select3')
 
 
 
 
852
  with col2:
853
  salary_var = st.number_input("Salary Max", min_value = 0, max_value = 20000, value = 20000, step = 100)
854
 
 
876
  player_select_df = handbuild_roo[['Player', 'Position', 'Team', 'Team_Total', 'Opp_Total', 'Salary', 'Median', '2x%', 'Order', 'Hand', 'Own%']].drop_duplicates(subset=['Player', 'Team']).copy()
877
 
878
  # If no teams selected, show all teams
879
+ if pos_select3:
880
  position_mask_2 = handbuild_roo['Position'].apply(lambda x: any(pos in x for pos in pos_select3))
881
  player_select_df = handbuild_roo[position_mask_2][['Player', 'Position', 'Team', 'Team_Total', 'Opp_Total', 'Salary', 'Median', '2x%', 'Order', 'Hand', 'Own%']].drop_duplicates(subset=['Player', 'Team']).sort_values(by='Order', ascending=True).copy()
882
  else: