nesticot commited on
Commit
3308044
·
verified ·
1 Parent(s): 91a5d22

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +30 -30
app.py CHANGED
@@ -822,39 +822,39 @@ def server(input, output, session):
822
  table.set_fontsize(12)
823
  table.scale(1, 1.5)
824
 
825
- if sport_id == 1:
826
 
827
-
828
-
829
- url_season = url = f"""
830
- https://www.fangraphs.com/api/leaders/major-league/data?age=&pos=all&stats=pit&lg=all&season={year}&season1={year}
831
- &startdate={year}-01-01&enddate={year}-12-01&ind=0&qual=0&type=8&month=33&pageitems=500000
832
- """
833
- data_season = requests.get(url_season).json()
834
- df_season = pl.DataFrame(data=data_season['data'], infer_schema_length=1000)
835
- df_season = df_season.with_columns(pl.lit('Season').alias('Time'))
836
- df_fg_filter = df_season.filter(pl.col('xMLBAMID')==int(input.pitcher_id()))
837
- metrics_data = {
838
- "G": f"{df_fg_filter['G'][0]:.0f}",
839
- "IP": f"{df_fg_filter['IP'][0]:.1f}",
840
- "Pitches": f"{new_player_metrics['pitches'][0]:.0f}",
841
- "PA": f"{df_fg_filter['TBF'][0]:.0f}",
842
- "BIP": new_player_metrics['bip'][0],
843
- "ERA": f"{df_fg_filter['ERA'][0]:.2f}",
844
- "FIP": f"{df_fg_filter['FIP'][0]:.2f}",
845
- "WHIP": f"{df_fg_filter['WHIP'][0]:.2f}",
846
- }
847
 
848
-
849
- df_table = pd.DataFrame(metrics_data, index=[0])
850
 
851
- table = ax_table.table(cellText=df_table.values, colLabels=df_table.columns, cellLoc='center', loc='bottom', bbox=[0.07, 0, 0.86, 1])
852
- for key, cell in table.get_celld().items():
853
- if key[0] == 0:
854
- cell.set_text_props(fontweight='bold')
855
- table.auto_set_font_size(False)
856
- table.set_fontsize(12)
857
- table.scale(1, 1.5)
 
 
858
 
859
  # Additional subplots for spacing
860
  ax_top = fig.add_subplot(gs[0, :])
 
822
  table.set_fontsize(12)
823
  table.scale(1, 1.5)
824
 
825
+ if sport_id == 1:
826
 
827
+
828
+
829
+ url_season = url = f"""
830
+ https://www.fangraphs.com/api/leaders/major-league/data?age=&pos=all&stats=pit&lg=all&season={year}&season1={year}
831
+ &startdate={year}-01-01&enddate={year}-12-01&ind=0&qual=0&type=8&month=33&pageitems=500000
832
+ """
833
+ data_season = requests.get(url_season).json()
834
+ df_season = pl.DataFrame(data=data_season['data'], infer_schema_length=1000)
835
+ df_season = df_season.with_columns(pl.lit('Season').alias('Time'))
836
+ df_fg_filter = df_season.filter(pl.col('xMLBAMID')==int(pitcher_id))
837
+ metrics_data = {
838
+ "G": f"{df_fg_filter['G'][0]:.0f}",
839
+ "IP": f"{df_fg_filter['IP'][0]:.1f}",
840
+ "Pitches": f"{new_player_metrics['pitches'][0]:.0f}",
841
+ "PA": f"{df_fg_filter['TBF'][0]:.0f}",
842
+ "BIP": new_player_metrics['bip'][0],
843
+ "ERA": f"{df_fg_filter['ERA'][0]:.2f}",
844
+ "FIP": f"{df_fg_filter['FIP'][0]:.2f}",
845
+ "WHIP": f"{df_fg_filter['WHIP'][0]:.2f}",
846
+ }
847
 
 
 
848
 
849
+ df_table = pd.DataFrame(metrics_data, index=[0])
850
+
851
+ table = ax_table.table(cellText=df_table.values, colLabels=df_table.columns, cellLoc='center', loc='bottom', bbox=[0.07, 0, 0.86, 1])
852
+ for key, cell in table.get_celld().items():
853
+ if key[0] == 0:
854
+ cell.set_text_props(fontweight='bold')
855
+ table.auto_set_font_size(False)
856
+ table.set_fontsize(12)
857
+ table.scale(1, 1.5)
858
 
859
  # Additional subplots for spacing
860
  ax_top = fig.add_subplot(gs[0, :])