Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -800,6 +800,31 @@ 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 |
df_table = pd.DataFrame(metrics_data, index=[0])
|
| 804 |
|
| 805 |
table = ax_table.table(cellText=df_table.values, colLabels=df_table.columns, cellLoc='center', loc='bottom', bbox=[0.07, 0, 0.86, 1])
|
|
|
|
| 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'))
|
| 815 |
+
df_fg_filter = df_season.filter(pl.col('xMLBAMID')==int(input.pitcher_id()))
|
| 816 |
+
metrics_data = {
|
| 817 |
+
"G": f"{df_fg_filter['G'][0]:.0f}",
|
| 818 |
+
"IP": f"{df_fg_filter['IP'][0]:.1f}",
|
| 819 |
+
"Pitches": f"{new_player_metrics['pitches'][0]:.0f}",
|
| 820 |
+
"PA": f"{df_fg_filter['TBF'][0]:.0f}",
|
| 821 |
+
"BIP": new_player_metrics['bip'][0],
|
| 822 |
+
"ERA": f"{df_fg_filter['ERA'][0]:.2f}",
|
| 823 |
+
"FIP": f"{df_fg_filter['FIP'][0]:.2f}",
|
| 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])
|