nesticot commited on
Commit
831fbcf
·
verified ·
1 Parent(s): 569fa13

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -5
app.py CHANGED
@@ -169,7 +169,7 @@ app_ui = ui.page_fluid(
169
  # ui.nav(
170
  # "Pitching Summary",
171
  ui.card(
172
- {"style": "width: 870px;"},
173
  ui.head_content(
174
  ui.tags.script(src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.8.5/d3.min.js"),
175
  ui.tags.script(src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"),
@@ -522,8 +522,8 @@ def server(input, output, session):
522
  }
523
 
524
  return ui.output_plot('plot',
525
- width='800px',
526
- height='800px',
527
  brush=ui.brush_opts(**brush_opts_kwargs))
528
 
529
  @render.table
@@ -608,6 +608,7 @@ def server(input, output, session):
608
  pl.col('release_pos_x').drop_nans().mean().round(1).alias('x0'),
609
  pl.col('release_pos_z').drop_nans().mean().round(1).alias('z0'),
610
  pl.col('tj_stuff_plus').drop_nans().mean().round(0).alias('tj_stuff_plus'),
 
611
  ])
612
  .with_columns(
613
  (pl.col('pitches') / pl.col('pitches').sum().over('pitcher_id'))
@@ -617,7 +618,7 @@ def server(input, output, session):
617
  )
618
  )).sort('proportion', descending=True).
619
  select(["pitch_description", "pitches", "proportion", "start_speed", "ivb", "hb",
620
- "spin_rate", "x0", "z0",'tj_stuff_plus'])
621
  .with_columns(
622
  pl.when(pl.col("pitch_description") == "Four-Seam Fastball")
623
  .then(pl.lit("4-Seam"))
@@ -634,7 +635,8 @@ def server(input, output, session):
634
  'spin_rate': 'Spin',
635
  'x0': 'hRel',
636
  'z0': 'vRel',
637
- 'tj_stuff_plus': 'tjStuff+'
 
638
  }))
639
 
640
  brushed_df_final_pd = brushed_df_final.to_pandas()
@@ -686,6 +688,7 @@ def server(input, output, session):
686
  .set_table_styles([{'selector': 'thead th:nth-child(6)', 'props': [('min-width', '40px')]}], overwrite=False)
687
  .set_table_styles([{'selector': 'thead th:nth-child(7)', 'props': [('min-width', '40px')]}], overwrite=False)
688
  .set_table_styles([{'selector': 'thead th:nth-child(8)', 'props': [('min-width', '40px')]}], overwrite=False)
 
689
  .background_gradient(cmap=cmap_sum,subset = (brushed_df_final.columns[-1]),vmin=80,vmax=120)
690
  .applymap(lambda x: f'background-color: {dict_pitch_name.get(x, "")}', subset=['Pitch Type'])
691
  .applymap(lambda x: f'background-color: black' if x == 0 else '', subset=['Spin'])
 
169
  # ui.nav(
170
  # "Pitching Summary",
171
  ui.card(
172
+ {"style": "width: 970px;"},
173
  ui.head_content(
174
  ui.tags.script(src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.8.5/d3.min.js"),
175
  ui.tags.script(src="https://html2canvas.hertzen.com/dist/html2canvas.min.js"),
 
522
  }
523
 
524
  return ui.output_plot('plot',
525
+ width='900px',
526
+ height='900px',
527
  brush=ui.brush_opts(**brush_opts_kwargs))
528
 
529
  @render.table
 
608
  pl.col('release_pos_x').drop_nans().mean().round(1).alias('x0'),
609
  pl.col('release_pos_z').drop_nans().mean().round(1).alias('z0'),
610
  pl.col('tj_stuff_plus').drop_nans().mean().round(0).alias('tj_stuff_plus'),
611
+ pl.col('pitch_grade').drop_nans().mean().round(0).alias('pitch_grade'),
612
  ])
613
  .with_columns(
614
  (pl.col('pitches') / pl.col('pitches').sum().over('pitcher_id'))
 
618
  )
619
  )).sort('proportion', descending=True).
620
  select(["pitch_description", "pitches", "proportion", "start_speed", "ivb", "hb",
621
+ "spin_rate", "x0", "z0",'tj_stuff_plus','pitch_grade'])
622
  .with_columns(
623
  pl.when(pl.col("pitch_description") == "Four-Seam Fastball")
624
  .then(pl.lit("4-Seam"))
 
635
  'spin_rate': 'Spin',
636
  'x0': 'hRel',
637
  'z0': 'vRel',
638
+ 'tj_stuff_plus': 'tjStuff+',
639
+ 'pitch_grade': 'Grade'
640
  }))
641
 
642
  brushed_df_final_pd = brushed_df_final.to_pandas()
 
688
  .set_table_styles([{'selector': 'thead th:nth-child(6)', 'props': [('min-width', '40px')]}], overwrite=False)
689
  .set_table_styles([{'selector': 'thead th:nth-child(7)', 'props': [('min-width', '40px')]}], overwrite=False)
690
  .set_table_styles([{'selector': 'thead th:nth-child(8)', 'props': [('min-width', '40px')]}], overwrite=False)
691
+ .set_table_styles([{'selector': 'thead th:nth-child(9)', 'props': [('min-width', '40px')]}], overwrite=False)
692
  .background_gradient(cmap=cmap_sum,subset = (brushed_df_final.columns[-1]),vmin=80,vmax=120)
693
  .applymap(lambda x: f'background-color: {dict_pitch_name.get(x, "")}', subset=['Pitch Type'])
694
  .applymap(lambda x: f'background-color: black' if x == 0 else '', subset=['Spin'])