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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -15
app.py CHANGED
@@ -787,6 +787,17 @@ def server(input, output, session):
787
  "K": f"{new_player_metrics['k'][0]:.0f}",
788
  "BB": f"{new_player_metrics['bb'][0]:.0f}",
789
  }
 
 
 
 
 
 
 
 
 
 
 
790
  else:
791
  df_fg_filter = df_fg.filter(pl.col('minormasterid') == dict_mlb_fg[pitcher_id])
792
  # Metrics data table
@@ -800,15 +811,25 @@ def server(input, output, session):
800
  "FIP": f"{df_fg_filter['FIP'][0]:.2f}",
801
  "WHIP": f"{df_fg_filter['WHIP'][0]:.2f}",
802
  }
 
 
 
 
 
 
 
 
 
 
803
 
804
  if sport_id == 1:
805
 
806
- if int(input.level_input()) == 1:
807
- season = int(str(input.date_input())[:4])
808
- url_season = url = f"""
809
- https://www.fangraphs.com/api/leaders/major-league/data?age=&pos=all&stats=pit&lg=all&season={season}&season1={season}
810
- &startdate={season}-01-01&enddate={season}-12-01&ind=0&qual=0&type=8&month=33&pageitems=500000
811
- """
812
  data_season = requests.get(url_season).json()
813
  df_season = pl.DataFrame(data=data_season['data'], infer_schema_length=1000)
814
  df_season = df_season.with_columns(pl.lit('Season').alias('Time'))
@@ -824,16 +845,16 @@ def server(input, output, session):
824
  "WHIP": f"{df_fg_filter['WHIP'][0]:.2f}",
825
  }
826
 
 
 
827
 
828
- df_table = pd.DataFrame(metrics_data, index=[0])
829
-
830
- table = ax_table.table(cellText=df_table.values, colLabels=df_table.columns, cellLoc='center', loc='bottom', bbox=[0.07, 0, 0.86, 1])
831
- for key, cell in table.get_celld().items():
832
- if key[0] == 0:
833
- cell.set_text_props(fontweight='bold')
834
- table.auto_set_font_size(False)
835
- table.set_fontsize(12)
836
- table.scale(1, 1.5)
837
 
838
  # Additional subplots for spacing
839
  ax_top = fig.add_subplot(gs[0, :])
 
787
  "K": f"{new_player_metrics['k'][0]:.0f}",
788
  "BB": f"{new_player_metrics['bb'][0]:.0f}",
789
  }
790
+
791
+ df_table = pd.DataFrame(metrics_data, index=[0])
792
+
793
+ table = ax_table.table(cellText=df_table.values, colLabels=df_table.columns, cellLoc='center', loc='bottom', bbox=[0.07, 0, 0.86, 1])
794
+ for key, cell in table.get_celld().items():
795
+ if key[0] == 0:
796
+ cell.set_text_props(fontweight='bold')
797
+ table.auto_set_font_size(False)
798
+ table.set_fontsize(12)
799
+ table.scale(1, 1.5)
800
+
801
  else:
802
  df_fg_filter = df_fg.filter(pl.col('minormasterid') == dict_mlb_fg[pitcher_id])
803
  # Metrics data table
 
811
  "FIP": f"{df_fg_filter['FIP'][0]:.2f}",
812
  "WHIP": f"{df_fg_filter['WHIP'][0]:.2f}",
813
  }
814
+
815
+ df_table = pd.DataFrame(metrics_data, index=[0])
816
+
817
+ table = ax_table.table(cellText=df_table.values, colLabels=df_table.columns, cellLoc='center', loc='bottom', bbox=[0.07, 0, 0.86, 1])
818
+ for key, cell in table.get_celld().items():
819
+ if key[0] == 0:
820
+ cell.set_text_props(fontweight='bold')
821
+ table.auto_set_font_size(False)
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'))
 
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, :])