nesticot commited on
Commit
7da230d
·
verified ·
1 Parent(s): 19cef13

Update functions/pitch_summary_functions.py

Browse files
functions/pitch_summary_functions.py CHANGED
@@ -901,7 +901,9 @@ splits_title = {
901
  def fangraphs_pitching_leaderboards(season: int,
902
  split: str,
903
  start_date: str = '2024-01-01',
904
- end_date: str = '2024-12-31'):
 
 
905
  """
906
  Fetch pitching leaderboards data from Fangraphs.
907
 
@@ -926,7 +928,7 @@ def fangraphs_pitching_leaderboards(season: int,
926
  print(start_date,end_date)
927
  print(f'{season}-01-01',f'{season}-12-31')
928
 
929
- if start_date == f'{season}-01-01' and end_date == f'{season}-12-31':
930
 
931
  url = f"""
932
  https://www.fangraphs.com/api/leaders/major-league/data?age=&pos=all&stats=pit&lg=all&season={season}&season1={season}
@@ -1028,7 +1030,9 @@ def fangraphs_table(df: pl.DataFrame,
1028
  ax: plt.Axes,
1029
  player_input: str,
1030
  season: int,
1031
- split: str):
 
 
1032
  """
1033
  Create a table of Fangraphs pitching leaderboards data for a specific player.
1034
 
@@ -1051,7 +1055,9 @@ def fangraphs_table(df: pl.DataFrame,
1051
  df_fangraphs = fangraphs_pitching_leaderboards(season=season,
1052
  split=split,
1053
  start_date = start_date,
1054
- end_date = end_date)
 
 
1055
 
1056
  df_fangraphs = df_fangraphs.filter(pl.col('xMLBAMID') == player_input)
1057
 
@@ -1096,7 +1102,9 @@ def stat_summary_table(df: pl.DataFrame,
1096
  sport_id: int,
1097
  ax: plt.Axes,
1098
  split: str = 'All',
1099
- game_type: list = ['R']):
 
 
1100
  """
1101
  Create a summary table of player statistics.
1102
 
@@ -1165,7 +1173,7 @@ def stat_summary_table(df: pl.DataFrame,
1165
  new_column_names = ['$\\bf{IP}$', '$\\bf{PA}$', '$\\bf{WHIP}$', '$\\bf{ERA}$', '$\\bf{FIP}$', '$\\bf{K\%}$', '$\\bf{BB\%}$', '$\\bf{K-BB\%}$', '$\\bf{Strike\%}$']
1166
  title = f'{df["game_date"][0]} to {df["game_date"][-1]} ({type_dict[game_type[0]]}{split_title[split]})'
1167
  else:
1168
- fangraphs_table(df=df, ax=ax, player_input=player_input, season=int(df['game_date'][0][0:4]), split=split)
1169
  print("SEASON LONG DATA")
1170
  return
1171
 
 
901
  def fangraphs_pitching_leaderboards(season: int,
902
  split: str,
903
  start_date: str = '2024-01-01',
904
+ end_date: str = '2024-12-31',
905
+ start_date_input:str,
906
+ end_date_input:str):
907
  """
908
  Fetch pitching leaderboards data from Fangraphs.
909
 
 
928
  print(start_date,end_date)
929
  print(f'{season}-01-01',f'{season}-12-31')
930
 
931
+ if start_date_input == f'{season}-01-01' and end_date_input == f'{season}-12-31':
932
 
933
  url = f"""
934
  https://www.fangraphs.com/api/leaders/major-league/data?age=&pos=all&stats=pit&lg=all&season={season}&season1={season}
 
1030
  ax: plt.Axes,
1031
  player_input: str,
1032
  season: int,
1033
+ split: str,
1034
+ start_date_input:str,
1035
+ end_date_input:str):):
1036
  """
1037
  Create a table of Fangraphs pitching leaderboards data for a specific player.
1038
 
 
1055
  df_fangraphs = fangraphs_pitching_leaderboards(season=season,
1056
  split=split,
1057
  start_date = start_date,
1058
+ end_date = end_date,
1059
+ start_date_input=start_date_input,
1060
+ end_date_input=end_date_input)
1061
 
1062
  df_fangraphs = df_fangraphs.filter(pl.col('xMLBAMID') == player_input)
1063
 
 
1102
  sport_id: int,
1103
  ax: plt.Axes,
1104
  split: str = 'All',
1105
+ game_type: list = ['R'],
1106
+ start_date_input:str,
1107
+ end_date_input:str):
1108
  """
1109
  Create a summary table of player statistics.
1110
 
 
1173
  new_column_names = ['$\\bf{IP}$', '$\\bf{PA}$', '$\\bf{WHIP}$', '$\\bf{ERA}$', '$\\bf{FIP}$', '$\\bf{K\%}$', '$\\bf{BB\%}$', '$\\bf{K-BB\%}$', '$\\bf{Strike\%}$']
1174
  title = f'{df["game_date"][0]} to {df["game_date"][-1]} ({type_dict[game_type[0]]}{split_title[split]})'
1175
  else:
1176
+ fangraphs_table(df=df, ax=ax, player_input=player_input, season=int(df['game_date'][0][0:4]), split=split,start_date_input=start_date_input,end_date_input)
1177
  print("SEASON LONG DATA")
1178
  return
1179