Update functions/pitch_summary_functions.py
Browse files
functions/pitch_summary_functions.py
CHANGED
|
@@ -1073,6 +1073,12 @@ def stat_summary_table(df: pl.DataFrame,
|
|
| 1073 |
split : str, optional
|
| 1074 |
The split type (default is 'All').
|
| 1075 |
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1076 |
# Format start and end dates
|
| 1077 |
start_date_format = str(pd.to_datetime(df['game_date'][0]).strftime('%m/%d/%Y'))
|
| 1078 |
end_date_format = str(pd.to_datetime(df['game_date'][-1]).strftime('%m/%d/%Y'))
|
|
@@ -1107,10 +1113,10 @@ def stat_summary_table(df: pl.DataFrame,
|
|
| 1107 |
pitcher_stats_call_df_small = pitcher_stats_call_df.select(['inningsPitched', 'battersFaced', 'earnedRuns', 'hits', 'strikeOuts', 'baseOnBalls', 'hitByPitch', 'homeRuns', 'strikePercentage', 'whiffs'])
|
| 1108 |
new_column_names = ['$\\bf{IP}$', '$\\bf{PA}$', '$\\bf{ER}$', '$\\bf{H}$', '$\\bf{K}$', '$\\bf{BB}$', '$\\bf{HBP}$', '$\\bf{HR}$', '$\\bf{Strike\%}$', '$\\bf{Whiffs}$']
|
| 1109 |
title = f'{df["game_date"][0]} vs {df["batter_team"][0]}'
|
| 1110 |
-
elif sport_id != 1:
|
| 1111 |
pitcher_stats_call_df_small = pitcher_stats_call_df.select(['inningsPitched', 'battersFaced', 'whip', 'era', 'fip', 'k_percent', 'bb_percent', 'k_bb_percent', 'strikePercentage'])
|
| 1112 |
new_column_names = ['$\\bf{IP}$', '$\\bf{PA}$', '$\\bf{WHIP}$', '$\\bf{ERA}$', '$\\bf{FIP}$', '$\\bf{K\%}$', '$\\bf{BB\%}$', '$\\bf{K-BB\%}$', '$\\bf{Strike\%}$']
|
| 1113 |
-
title = f'{df["game_date"][0]} to {df["game_date"][-1]}'
|
| 1114 |
else:
|
| 1115 |
fangraphs_table(df=df, ax=ax, player_input=player_input, season=int(df['game_date'][0][0:4]), split=split)
|
| 1116 |
return
|
|
|
|
| 1073 |
split : str, optional
|
| 1074 |
The split type (default is 'All').
|
| 1075 |
"""
|
| 1076 |
+
|
| 1077 |
+
type_dict = {'R':'Regular Season',
|
| 1078 |
+
'S':'Spring',
|
| 1079 |
+
'P':'Playoffs' }
|
| 1080 |
+
|
| 1081 |
+
|
| 1082 |
# Format start and end dates
|
| 1083 |
start_date_format = str(pd.to_datetime(df['game_date'][0]).strftime('%m/%d/%Y'))
|
| 1084 |
end_date_format = str(pd.to_datetime(df['game_date'][-1]).strftime('%m/%d/%Y'))
|
|
|
|
| 1113 |
pitcher_stats_call_df_small = pitcher_stats_call_df.select(['inningsPitched', 'battersFaced', 'earnedRuns', 'hits', 'strikeOuts', 'baseOnBalls', 'hitByPitch', 'homeRuns', 'strikePercentage', 'whiffs'])
|
| 1114 |
new_column_names = ['$\\bf{IP}$', '$\\bf{PA}$', '$\\bf{ER}$', '$\\bf{H}$', '$\\bf{K}$', '$\\bf{BB}$', '$\\bf{HBP}$', '$\\bf{HR}$', '$\\bf{Strike\%}$', '$\\bf{Whiffs}$']
|
| 1115 |
title = f'{df["game_date"][0]} vs {df["batter_team"][0]}'
|
| 1116 |
+
elif sport_id != 1 or game_type in ['S','P']:
|
| 1117 |
pitcher_stats_call_df_small = pitcher_stats_call_df.select(['inningsPitched', 'battersFaced', 'whip', 'era', 'fip', 'k_percent', 'bb_percent', 'k_bb_percent', 'strikePercentage'])
|
| 1118 |
new_column_names = ['$\\bf{IP}$', '$\\bf{PA}$', '$\\bf{WHIP}$', '$\\bf{ERA}$', '$\\bf{FIP}$', '$\\bf{K\%}$', '$\\bf{BB\%}$', '$\\bf{K-BB\%}$', '$\\bf{Strike\%}$']
|
| 1119 |
+
title = f'{type_dict[game_type[0]]} {df["game_date"][0]} to {df["game_date"][-1]}'
|
| 1120 |
else:
|
| 1121 |
fangraphs_table(df=df, ax=ax, player_input=player_input, season=int(df['game_date'][0][0:4]), split=split)
|
| 1122 |
return
|