Spaces:
Running
Running
Commit
·
ba07c8b
1
Parent(s):
058e35a
Add HR/FB
Browse files- pitch_leaderboard.py +2 -2
- player_team_leaderboard.py +2 -2
- stats.py +2 -0
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%'],
|
| 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%']
|
| 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'],
|
| 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/OFFB']
|
| 55 |
}
|
| 56 |
|
| 57 |
all_cols = prefix_cols + sum(list(theme_to_cols.values()), [])
|
player_team_leaderboard.py
CHANGED
|
@@ -37,7 +37,7 @@ def create_player_team_leaderboard_app(player_team_type):
|
|
| 37 |
prefix_cols = [col for col in prefix_cols if col not in ('Pitcher', 'Throws')]
|
| 38 |
theme_to_cols = {
|
| 39 |
'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'Strike%', 'Ball%', 'F-Str%', 'PAR%', 'PLUS%'],
|
| 40 |
-
'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR%'],
|
| 41 |
'Approach': ['Zone%', 'Arm%', 'Glove%', 'High%', 'Low%', 'MM%', 'Behind%', 'Sec%']
|
| 42 |
}
|
| 43 |
all_cols = prefix_cols + sum(list(theme_to_cols.values()), [])
|
|
@@ -50,7 +50,7 @@ def create_player_team_leaderboard_app(player_team_type):
|
|
| 50 |
prefix_cols = [col for col in prefix_cols if col not in ('Batter', 'Bats')]
|
| 51 |
theme_to_cols = {
|
| 52 |
'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'PLUS%'],
|
| 53 |
-
'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR%']
|
| 54 |
}
|
| 55 |
all_cols = prefix_cols + sum(list(theme_to_cols.values()), [])
|
| 56 |
for theme, cols in theme_to_cols.items():
|
|
|
|
| 37 |
prefix_cols = [col for col in prefix_cols if col not in ('Pitcher', 'Throws')]
|
| 38 |
theme_to_cols = {
|
| 39 |
'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'Strike%', 'Ball%', 'F-Str%', 'PAR%', 'PLUS%'],
|
| 40 |
+
'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR%', 'HR/FB'],
|
| 41 |
'Approach': ['Zone%', 'Arm%', 'Glove%', 'High%', 'Low%', 'MM%', 'Behind%', 'Sec%']
|
| 42 |
}
|
| 43 |
all_cols = prefix_cols + sum(list(theme_to_cols.values()), [])
|
|
|
|
| 50 |
prefix_cols = [col for col in prefix_cols if col not in ('Batter', 'Bats')]
|
| 51 |
theme_to_cols = {
|
| 52 |
'Plate Discipline': ['Swing%', 'Z-Swing%', 'Chase%', 'Contact%', 'Z-Con%', 'O-Con%', 'SwStr%', 'Whiff%', 'CSW%', 'PLUS%'],
|
| 53 |
+
'Batted Ball': ['GB%', 'FB%', 'LD%', 'OFFB%', 'IFFB%', 'AIR%', 'HR%', 'HR/OFFB']
|
| 54 |
}
|
| 55 |
all_cols = prefix_cols + sum(list(theme_to_cols.values()), [])
|
| 56 |
for theme, cols in theme_to_cols.items():
|
stats.py
CHANGED
|
@@ -80,6 +80,8 @@ register_stat('IFFB%', pl.col('P'), True, Player.PITCHER, True)
|
|
| 80 |
register_stat('OFFB%', pl.col('F'), True, Player.BATTER, True)
|
| 81 |
register_stat('AIR%', pl.col('F') + pl.col('P') + pl.col('L'), True, Player.BATTER, True)
|
| 82 |
register_stat('HR%', (pl.col('presult') == 'Home run').sum() / pa, True, Player.BATTER)
|
|
|
|
|
|
|
| 83 |
|
| 84 |
# register_stat('Usage', pl.col('count')/pl.sum('count').over('pitId'), True, None)
|
| 85 |
register_stat('Usage', pl.len()/pl.first('Pitches'), True, None)
|
|
|
|
| 80 |
register_stat('OFFB%', pl.col('F'), True, Player.BATTER, True)
|
| 81 |
register_stat('AIR%', pl.col('F') + pl.col('P') + pl.col('L'), True, Player.BATTER, True)
|
| 82 |
register_stat('HR%', (pl.col('presult') == 'Home run').sum() / pa, True, Player.BATTER)
|
| 83 |
+
register_stat('HR/FB', (pl.col('presult') == 'Home run').sum() / (pl.col('aux_bresult').struct.field('batType') == 'F').sum(), True, Player.BATTER)
|
| 84 |
+
register_stat('HR/OFFB', (pl.col('presult') == 'Home run').sum() / (pl.col('aux_bresult').struct.field('batType').is_in(['F', 'P'])).sum(), True, Player.BATTER)
|
| 85 |
|
| 86 |
# register_stat('Usage', pl.col('count')/pl.sum('count').over('pitId'), True, None)
|
| 87 |
register_stat('Usage', pl.len()/pl.first('Pitches'), True, None)
|