James McCool commited on
Commit
c9fd1e3
·
1 Parent(s): 053e7df

Refactor player information forms layout in app.py

Browse files

- Updated the layout of player information forms to improve user experience by organizing the position selection and comparison forms into separate columns.
- Adjusted the data display for player exposure comparison to enhance clarity and visual representation of the data.

Files changed (1) hide show
  1. app.py +41 -39
app.py CHANGED
@@ -396,47 +396,49 @@ with tab2:
396
  with st.container():
397
  tab1, tab2, tab3, tab4, tab5 = st.tabs(['Player Used Info', 'Stack Used Info', 'Stack Size Info', 'General Info', 'Duplication Info'])
398
  with tab1:
399
- with st.form(key='player_info_pos_form'):
400
- col1, col2 = st.columns(2)
401
- with col1:
402
- pos_var = st.selectbox("Which position(s) would you like to view?", ['All', 'Specific'], key='pos_var')
403
- with col2:
404
- if sport_select == 'MLB':
405
- pos_select = st.multiselect("Select your position(s)", ['P', 'C', '1B', '2B', '3B', 'SS', 'OF'], key='pos_select')
406
- elif sport_select == 'NBA':
407
- pos_select = st.multiselect("Select your position(s)", ['PG', 'SG', 'SF', 'PF', 'C'], key='pos_select')
408
- elif sport_select == 'WNBA':
409
- pos_select = st.multiselect("Select your position(s)", ['PG', 'SG', 'SF', 'PF'], key='pos_select')
410
- elif sport_select == 'NFL':
411
- pos_select = st.multiselect("Select your position(s)", ['QB', 'RB', 'WR', 'TE', 'DST'], key='pos_select')
412
- elif sport_select == 'NHL':
413
- pos_select = st.multiselect("Select your position(s)", ['W', 'C', 'D', 'G'], key='pos_select')
414
- elif sport_select == 'MMA':
415
- pos_select = st.multiselect("Select your position(s)", ['All the same position', 'So', 'Yeah', 'Idk'], key='pos_select')
416
- elif sport_select == 'GOLF':
417
- pos_select = st.multiselect("Select your position(s)", ['All the same position', 'So', 'Yeah', 'Idk'], key='pos_select')
418
- submitted = st.form_submit_button("Submit")
419
- if submitted:
420
- if pos_var == 'Specific':
421
- pos_select = pos_select
422
- else:
423
- pos_select = None
424
-
425
- with st.form(key='player_exp_comp_form'):
426
- col1, col2 = st.columns(2)
427
- with col1:
428
- comp_player_var = st.selectbox("Would you like to compare with anyone?", ['No', 'Yes'], key='comp_player_var')
429
- with col2:
430
- comp_player_select = st.multiselect("Select players to compare with:", st.session_state['display_contest_info']['BaseName'].sort_values().unique(), key='comp_player_select')
431
- submitted = st.form_submit_button("Submit")
432
- if submitted:
433
- if comp_player_var == 'No':
434
- comp_player_select = None
435
- else:
436
- comp_player_select = comp_player_select
 
 
437
  if comp_player_var == 'Yes':
438
  player_exp_comp = create_player_comparison(st.session_state['display_contest_info'], st.session_state['player_columns'], comp_player_select)
439
- st.dataframe(player_exp_comp.style.background_gradient(cmap='RdYlGn', axis=1).format(formatter='{:.2%}', subset=player_exp_comp.select_dtypes(include=['number']).columns), hide_index=True)
440
  else:
441
  if st.session_state['entry_parse_var'] == 'All':
442
 
 
396
  with st.container():
397
  tab1, tab2, tab3, tab4, tab5 = st.tabs(['Player Used Info', 'Stack Used Info', 'Stack Size Info', 'General Info', 'Duplication Info'])
398
  with tab1:
399
+ player_pos_form_col, player_comp_form_col = st.columns(2)
400
+ with player_pos_form_col:
401
+ with st.form(key='player_info_pos_form'):
402
+ col1, col2 = st.columns(2)
403
+ with col1:
404
+ pos_var = st.selectbox("Which position(s) would you like to view?", ['All', 'Specific'], key='pos_var')
405
+ with col2:
406
+ if sport_select == 'MLB':
407
+ pos_select = st.multiselect("Select your position(s)", ['P', 'C', '1B', '2B', '3B', 'SS', 'OF'], key='pos_select')
408
+ elif sport_select == 'NBA':
409
+ pos_select = st.multiselect("Select your position(s)", ['PG', 'SG', 'SF', 'PF', 'C'], key='pos_select')
410
+ elif sport_select == 'WNBA':
411
+ pos_select = st.multiselect("Select your position(s)", ['PG', 'SG', 'SF', 'PF'], key='pos_select')
412
+ elif sport_select == 'NFL':
413
+ pos_select = st.multiselect("Select your position(s)", ['QB', 'RB', 'WR', 'TE', 'DST'], key='pos_select')
414
+ elif sport_select == 'NHL':
415
+ pos_select = st.multiselect("Select your position(s)", ['W', 'C', 'D', 'G'], key='pos_select')
416
+ elif sport_select == 'MMA':
417
+ pos_select = st.multiselect("Select your position(s)", ['All the same position', 'So', 'Yeah', 'Idk'], key='pos_select')
418
+ elif sport_select == 'GOLF':
419
+ pos_select = st.multiselect("Select your position(s)", ['All the same position', 'So', 'Yeah', 'Idk'], key='pos_select')
420
+ submitted = st.form_submit_button("Submit")
421
+ if submitted:
422
+ if pos_var == 'Specific':
423
+ pos_select = pos_select
424
+ else:
425
+ pos_select = None
426
+ with player_comp_form_col:
427
+ with st.form(key='player_exp_comp_form'):
428
+ col1, col2 = st.columns(2)
429
+ with col1:
430
+ comp_player_var = st.selectbox("Would you like to compare with anyone?", ['No', 'Yes'], key='comp_player_var')
431
+ with col2:
432
+ comp_player_select = st.multiselect("Select players to compare with:", st.session_state['display_contest_info']['BaseName'].sort_values().unique(), key='comp_player_select')
433
+ submitted = st.form_submit_button("Submit")
434
+ if submitted:
435
+ if comp_player_var == 'No':
436
+ comp_player_select = None
437
+ else:
438
+ comp_player_select = comp_player_select
439
  if comp_player_var == 'Yes':
440
  player_exp_comp = create_player_comparison(st.session_state['display_contest_info'], st.session_state['player_columns'], comp_player_select)
441
+ st.dataframe(player_exp_comp.style.background_gradient(cmap='RdYlGn', axis=0).format(formatter='{:.2%}', subset=player_exp_comp.select_dtypes(include=['number']).columns), hide_index=True)
442
  else:
443
  if st.session_state['entry_parse_var'] == 'All':
444