patrickramos commited on
Commit
11fde81
·
1 Parent(s): bc4f4c3

Remove velo outliers

Browse files
Files changed (1) hide show
  1. plotting.py +3 -1
plotting.py CHANGED
@@ -93,9 +93,11 @@ def plot_loc(ax, locs):
93
  def plot_velo(ax, velos):
94
  trans = transforms.blended_transform_factory(ax.transData, ax.transAxes)
95
  for (pitch,), _velos in velos.group_by('general_ballKind_code'):
 
 
96
  if len(_velos) <= 1:
97
  continue
98
-
99
  violin = ax.violinplot(_velos['ballSpeed_mph'], orientation='horizontal', side='high', showextrema=False)
100
  for _violin in violin['bodies']:
101
  _violin.set_facecolor(ball_kind_code_to_color[pitch])
 
93
  def plot_velo(ax, velos):
94
  trans = transforms.blended_transform_factory(ax.transData, ax.transAxes)
95
  for (pitch,), _velos in velos.group_by('general_ballKind_code'):
96
+ _velos = _velos.filter(((pl.col('ballSpeed_mph') - pl.col('ballSpeed_mph').mean())/ pl.col('ballSpeed_mph').std()).abs() < 3)
97
+
98
  if len(_velos) <= 1:
99
  continue
100
+
101
  violin = ax.violinplot(_velos['ballSpeed_mph'], orientation='horizontal', side='high', showextrema=False)
102
  for _violin in violin['bodies']:
103
  _violin.set_facecolor(ball_kind_code_to_color[pitch])