nesticot commited on
Commit
235ac0d
·
verified ·
1 Parent(s): 5a884a8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -10
app.py CHANGED
@@ -766,7 +766,7 @@ def server(input, output, session):
766
 
767
 
768
 
769
- brushed_df_final = (((brushed_df.group_by(['pitcher_id', 'pitch_type']).agg([
770
  pl.col('is_pitch').drop_nans().count().alias('pitches'),
771
  pl.col('start_speed').drop_nans().mean().round(1).alias('start_speed'),
772
  pl.col('vb').drop_nans().mean().round(1).alias('vb'),
@@ -786,22 +786,22 @@ def server(input, output, session):
786
  .alias('proportion')
787
  )
788
  )).sort('proportion', descending=True).
789
- select(["pitch_type", "pitches", "proportion", "start_speed", "ivb", "hb","vaa",
790
  "spin_rate", "x0", "z0",'tj_stuff_plus','pitch_grade'])
791
  .with_columns(
792
- pl.when(pl.col("pitch_type") == "Four-Seam Fastball")
793
  .then(pl.lit("4-Seam"))
794
- .otherwise(pl.col("pitch_type"))
795
- .alias("pitch_type")
796
  )
797
  .rename({
798
- 'pitch_type': 'Pitch Type',
799
  'pitches': 'Pitches',
800
  'proportion': 'Prop',
801
  'start_speed': 'Velo',
802
  'ivb': 'iVB',
803
  'hb': 'HB',
804
- 'vaa': 'VAA',
805
  'spin_rate': 'Spin',
806
  'x0': 'hRel',
807
  'z0': 'vRel',
@@ -845,13 +845,13 @@ def server(input, output, session):
845
  .hide_index()
846
  .set_properties(**{'border': '1px black solid !important'})
847
  .format('{:.0%}',subset=(brushed_df_final.columns[2]))
848
- .format('{:.1f}',subset=(brushed_df_final.columns[6]))
849
  .format('{:.0f}',subset=(brushed_df_final.columns[-1]))
850
  .format('{:.0f}',subset=(brushed_df_final.columns[-2]))
851
  .set_properties(subset=brushed_df_final.columns, **{'height': '30px'})
852
  .set_table_styles([{'selector': 'thead th', 'props': [('height', '30px')]}], overwrite=False)
853
  # .set_table_styles([{'selector': 'table', 'props': [('width', '100px')]}], overwrite=False)
854
- .set_table_styles([{'selector': 'thead th:nth-child(1)', 'props': [('min-width', '115px')]}], overwrite=False)
855
  .set_table_styles([{'selector': 'thead th:nth-child(2)', 'props': [('min-width', '40px')]}], overwrite=False)
856
  .set_table_styles([{'selector': 'thead th:nth-child(3)', 'props': [('min-width', '40px')]}], overwrite=False)
857
  .set_table_styles([{'selector': 'thead th:nth-child(4)', 'props': [('min-width', '40px')]}], overwrite=False)
@@ -860,7 +860,6 @@ def server(input, output, session):
860
  .set_table_styles([{'selector': 'thead th:nth-child(7)', 'props': [('min-width', '40px')]}], overwrite=False)
861
  .set_table_styles([{'selector': 'thead th:nth-child(8)', 'props': [('min-width', '40px')]}], overwrite=False)
862
  .set_table_styles([{'selector': 'thead th:nth-child(9)', 'props': [('min-width', '40px')]}], overwrite=False)
863
- .set_table_styles([{'selector': 'thead th:nth-child(10)', 'props': [('min-width', '40px')]}], overwrite=False)
864
  .background_gradient(cmap=cmap_sum,subset = (brushed_df_final.columns[-2]),vmin=80,vmax=120)
865
  .background_gradient(cmap=cmap_sum,subset = (brushed_df_final.columns[-1]),vmin=20,vmax=80)
866
  .applymap(lambda x: f'background-color: {dict_pitch_name.get(x, "")}80', subset=['Pitch Type'])
 
766
 
767
 
768
 
769
+ brushed_df_final = (((brushed_df.group_by(['pitcher_id', 'pitch_description']).agg([
770
  pl.col('is_pitch').drop_nans().count().alias('pitches'),
771
  pl.col('start_speed').drop_nans().mean().round(1).alias('start_speed'),
772
  pl.col('vb').drop_nans().mean().round(1).alias('vb'),
 
786
  .alias('proportion')
787
  )
788
  )).sort('proportion', descending=True).
789
+ select(["pitch_description", "pitches", "proportion", "start_speed", "ivb", "hb",
790
  "spin_rate", "x0", "z0",'tj_stuff_plus','pitch_grade'])
791
  .with_columns(
792
+ pl.when(pl.col("pitch_description") == "Four-Seam Fastball")
793
  .then(pl.lit("4-Seam"))
794
+ .otherwise(pl.col("pitch_description"))
795
+ .alias("pitch_description")
796
  )
797
  .rename({
798
+ 'pitch_description': 'Pitch Type',
799
  'pitches': 'Pitches',
800
  'proportion': 'Prop',
801
  'start_speed': 'Velo',
802
  'ivb': 'iVB',
803
  'hb': 'HB',
804
+ # 'vaa': 'VAA',
805
  'spin_rate': 'Spin',
806
  'x0': 'hRel',
807
  'z0': 'vRel',
 
845
  .hide_index()
846
  .set_properties(**{'border': '1px black solid !important'})
847
  .format('{:.0%}',subset=(brushed_df_final.columns[2]))
848
+ .format('{:.0f}',subset=(brushed_df_final.columns[6]))
849
  .format('{:.0f}',subset=(brushed_df_final.columns[-1]))
850
  .format('{:.0f}',subset=(brushed_df_final.columns[-2]))
851
  .set_properties(subset=brushed_df_final.columns, **{'height': '30px'})
852
  .set_table_styles([{'selector': 'thead th', 'props': [('height', '30px')]}], overwrite=False)
853
  # .set_table_styles([{'selector': 'table', 'props': [('width', '100px')]}], overwrite=False)
854
+ .set_table_styles([{'selector': 'thead th:nth-child(1)', 'props': [('min-width', '155px')]}], overwrite=False)
855
  .set_table_styles([{'selector': 'thead th:nth-child(2)', 'props': [('min-width', '40px')]}], overwrite=False)
856
  .set_table_styles([{'selector': 'thead th:nth-child(3)', 'props': [('min-width', '40px')]}], overwrite=False)
857
  .set_table_styles([{'selector': 'thead th:nth-child(4)', 'props': [('min-width', '40px')]}], overwrite=False)
 
860
  .set_table_styles([{'selector': 'thead th:nth-child(7)', 'props': [('min-width', '40px')]}], overwrite=False)
861
  .set_table_styles([{'selector': 'thead th:nth-child(8)', 'props': [('min-width', '40px')]}], overwrite=False)
862
  .set_table_styles([{'selector': 'thead th:nth-child(9)', 'props': [('min-width', '40px')]}], overwrite=False)
 
863
  .background_gradient(cmap=cmap_sum,subset = (brushed_df_final.columns[-2]),vmin=80,vmax=120)
864
  .background_gradient(cmap=cmap_sum,subset = (brushed_df_final.columns[-1]),vmin=20,vmax=80)
865
  .applymap(lambda x: f'background-color: {dict_pitch_name.get(x, "")}80', subset=['Pitch Type'])