James McCool commited on
Commit
326a55d
·
1 Parent(s): 1130418

Optimize game rotation timeline visualization with refined sorting and data processing

Browse files
Files changed (1) hide show
  1. app.py +7 -8
app.py CHANGED
@@ -752,14 +752,17 @@ with tab5:
752
  display = st.container()
753
  stats_disp = st.container()
754
  check_rotation = working_data[working_data['backlog_lookup'] == game_id_var]
755
- check_rotation = team_backlog.sort_values(by=['GAME_DATE', 'Finish'], ascending=[False, True])
756
-
 
 
 
757
  fig = go.Figure()
758
 
759
- # Add bars for each shift
760
  for idx, row in check_rotation.iterrows():
761
  fig.add_trace(go.Bar(
762
- x=[row['minutes']], # Width of bar
763
  y=[row['Task']],
764
  base=row['Start'], # Start position of bar
765
  orientation='h',
@@ -785,10 +788,6 @@ with tab5:
785
  fig.add_vline(x=12, line_width=3, line_dash="dash", line_color="green")
786
  fig.add_vline(x=24, line_width=3, line_dash="dash", line_color="green")
787
  fig.add_vline(x=36, line_width=3, line_dash="dash", line_color="green")
788
-
789
- game_rot_stats = check_rotation.reindex(game_rot_cols,axis="columns")
790
- game_rot_stats = game_rot_stats.drop_duplicates(subset='PLAYER_NAME')
791
-
792
  # pages = pages.set_index('Player')
793
  display.plotly_chart(fig, use_container_width=True)
794
  stats_disp.dataframe(game_rot_stats.style.format(precision=2), hide_index=True, use_container_width = True)
 
752
  display = st.container()
753
  stats_disp = st.container()
754
  check_rotation = working_data[working_data['backlog_lookup'] == game_id_var]
755
+ check_rotation = check_rotation.sort_values(by='Start', ascending=True)
756
+ game_rot_stats = check_rotation.reindex(game_rot_cols,axis="columns")
757
+ game_rot_stats = game_rot_stats.drop_duplicates(subset='PLAYER_NAME')
758
+
759
+ # Create figure
760
  fig = go.Figure()
761
 
762
+ # Add bars for each rotation shift
763
  for idx, row in check_rotation.iterrows():
764
  fig.add_trace(go.Bar(
765
+ x=[row['Finish'] - row['Start']], # Width of bar
766
  y=[row['Task']],
767
  base=row['Start'], # Start position of bar
768
  orientation='h',
 
788
  fig.add_vline(x=12, line_width=3, line_dash="dash", line_color="green")
789
  fig.add_vline(x=24, line_width=3, line_dash="dash", line_color="green")
790
  fig.add_vline(x=36, line_width=3, line_dash="dash", line_color="green")
 
 
 
 
791
  # pages = pages.set_index('Player')
792
  display.plotly_chart(fig, use_container_width=True)
793
  stats_disp.dataframe(game_rot_stats.style.format(precision=2), hide_index=True, use_container_width = True)