patrickramos commited on
Commit
bff18b4
·
1 Parent(s): d3c849d

Add Cent% and Oppo%

Browse files
Files changed (4) hide show
  1. data.py +1 -1
  2. pitch_leaderboard.py +2 -2
  3. player_team_leaderboard.py +2 -2
  4. stats.py +1 -1
data.py CHANGED
@@ -23,7 +23,7 @@ from convert import (
23
 
24
  DATA_PATH = './files'
25
 
26
- assert (USE_CACHE := os.getenv('USE_CACHE', 'False')) in ('True', 'False')
27
  assert (PULL_NPB_DATA := os.getenv('PULL_NPB_DATA', 'True')) in ('True', 'False')
28
 
29
  if PULL_NPB_DATA == 'True':
 
23
 
24
  DATA_PATH = './files'
25
 
26
+ # assert (USE_CACHE := os.getenv('USE_CACHE', 'False')) in ('True', 'False')
27
  assert (PULL_NPB_DATA := os.getenv('PULL_NPB_DATA', 'True')) in ('True', 'False')
28
 
29
  if PULL_NPB_DATA == 'True':
pitch_leaderboard.py CHANGED
@@ -41,7 +41,7 @@ def create_pitch_leaderboard(player_team_type):
41
  prefix_cols = [col for col in prefix_cols if col not in ('Pitcher', 'Throws')]
42
  theme_to_cols = {
43
  'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'Strike%', 'Ball%', 'F-Str%', 'PAR%', 'PLUS%'],
44
- 'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR/FB', 'Pull%', 'Pull AIR%'],
45
  'Approach': ['Zone%', 'Arm%', 'Glove%', 'High%', 'Low%', 'MM%', 'Behind%']
46
  }
47
 
@@ -51,7 +51,7 @@ def create_pitch_leaderboard(player_team_type):
51
  prefix_cols = [col for col in prefix_cols if col not in ('Batter', 'Bats')]
52
  theme_to_cols = {
53
  'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'PLUS%'],
54
- 'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR/FB', 'Pull%', 'Pull AIR%']
55
  }
56
 
57
  all_cols = prefix_cols + sum(list(theme_to_cols.values()), [])
 
41
  prefix_cols = [col for col in prefix_cols if col not in ('Pitcher', 'Throws')]
42
  theme_to_cols = {
43
  'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'Strike%', 'Ball%', 'F-Str%', 'PAR%', 'PLUS%'],
44
+ 'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR/FB', 'Pull%', 'Cent%', 'Oppo%', 'Pull AIR%'],
45
  'Approach': ['Zone%', 'Arm%', 'Glove%', 'High%', 'Low%', 'MM%', 'Behind%']
46
  }
47
 
 
51
  prefix_cols = [col for col in prefix_cols if col not in ('Batter', 'Bats')]
52
  theme_to_cols = {
53
  'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'PLUS%'],
54
+ 'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR/FB', 'Pull%', 'Cent%', 'Oppo%', 'Pull AIR%']
55
  }
56
 
57
  all_cols = prefix_cols + sum(list(theme_to_cols.values()), [])
player_team_leaderboard.py CHANGED
@@ -33,7 +33,7 @@ def create_player_team_leaderboard_app(player_team_type):
33
  prefix_cols = [col for col in prefix_cols if col not in ('Pitcher', 'Throws')]
34
  theme_to_cols = {
35
  'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'Strike%', 'Ball%', 'F-Str%', 'PAR%', 'PLUS%'],
36
- 'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR%', 'HR/FB', 'Pull%', 'Pull AIR%'],
37
  'Approach': ['Zone%', 'Arm%', 'Glove%', 'High%', 'Low%', 'MM%', 'Behind%', 'Sec%']
38
  }
39
  all_cols = prefix_cols + sum(list(theme_to_cols.values()), [])
@@ -46,7 +46,7 @@ def create_player_team_leaderboard_app(player_team_type):
46
  prefix_cols = [col for col in prefix_cols if col not in ('Batter', 'Bats')]
47
  theme_to_cols = {
48
  'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'PLUS%'],
49
- 'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR%', 'HR/FB', 'Pull%', 'Pull AIR%']
50
  }
51
  all_cols = prefix_cols + sum(list(theme_to_cols.values()), [])
52
  for theme, cols in theme_to_cols.items():
 
33
  prefix_cols = [col for col in prefix_cols if col not in ('Pitcher', 'Throws')]
34
  theme_to_cols = {
35
  'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'Strike%', 'Ball%', 'F-Str%', 'PAR%', 'PLUS%'],
36
+ 'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR%', 'HR/FB', 'Pull%', 'Cent%', 'Oppo%', 'Pull AIR%'],
37
  'Approach': ['Zone%', 'Arm%', 'Glove%', 'High%', 'Low%', 'MM%', 'Behind%', 'Sec%']
38
  }
39
  all_cols = prefix_cols + sum(list(theme_to_cols.values()), [])
 
46
  prefix_cols = [col for col in prefix_cols if col not in ('Batter', 'Bats')]
47
  theme_to_cols = {
48
  'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'PLUS%'],
49
+ 'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR%', 'HR/FB', 'Pull%', 'Cent%', 'Oppo%', 'Pull AIR%']
50
  }
51
  all_cols = prefix_cols + sum(list(theme_to_cols.values()), [])
52
  for theme, cols in theme_to_cols.items():
stats.py CHANGED
@@ -88,7 +88,7 @@ register_stat('IFFB%', pl.col('P'), True, Player.PITCHER, True)
88
  register_stat('OFFB%', pl.col('F'), True, Player.BATTER, True)
89
  register_stat('AIR%', pl.col('F') + pl.col('P') + pl.col('L'), True, Player.BATTER, True)
90
  register_stat('Pull%', pl.col('Pull'), True, Player.BATTER, True)
91
- register_stat('Center%', pl.col('Pull'), True, None, True)
92
  register_stat('Oppo%', pl.col('Oppo'), True, None, True)
93
  register_stat('Pull AIR%', (is_bip & (pl.col('batted_ball_direction') == 'Pull') & pl.col('batType').is_in(['F', 'L', 'P'])).sum() / is_bip.sum(), True, Player.BATTER)
94
  register_stat('HR%', (pl.col('presult') == 'Home run').sum() / pa, True, Player.BATTER)
 
88
  register_stat('OFFB%', pl.col('F'), True, Player.BATTER, True)
89
  register_stat('AIR%', pl.col('F') + pl.col('P') + pl.col('L'), True, Player.BATTER, True)
90
  register_stat('Pull%', pl.col('Pull'), True, Player.BATTER, True)
91
+ register_stat('Cent%', pl.col('Cent'), True, None, True)
92
  register_stat('Oppo%', pl.col('Oppo'), True, None, True)
93
  register_stat('Pull AIR%', (is_bip & (pl.col('batted_ball_direction') == 'Pull') & pl.col('batType').is_in(['F', 'L', 'P'])).sum() / is_bip.sum(), True, Player.BATTER)
94
  register_stat('HR%', (pl.col('presult') == 'Home run').sum() / pa, True, Player.BATTER)