Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -645,46 +645,47 @@ def server(input, output, session):
|
|
| 645 |
}
|
| 646 |
levelt = {
|
| 647 |
11:1,
|
| 648 |
-
14:4
|
|
|
|
| 649 |
}
|
| 650 |
|
| 651 |
-
|
| 652 |
-
|
| 653 |
-
|
| 654 |
-
|
| 655 |
-
|
| 656 |
-
|
| 657 |
-
|
| 658 |
-
|
| 659 |
-
|
| 660 |
-
|
| 661 |
-
|
| 662 |
-
|
| 663 |
-
|
| 664 |
-
|
| 665 |
-
|
| 666 |
-
|
| 667 |
-
|
| 668 |
-
|
| 669 |
-
|
| 670 |
-
|
| 671 |
-
|
| 672 |
-
|
| 673 |
-
|
| 674 |
-
|
| 675 |
-
|
| 676 |
-
|
| 677 |
-
|
| 678 |
-
|
| 679 |
-
|
| 680 |
-
|
| 681 |
-
|
| 682 |
-
|
| 683 |
-
|
| 684 |
-
|
| 685 |
-
|
| 686 |
-
|
| 687 |
-
|
| 688 |
|
| 689 |
# Additional subplots for spacing
|
| 690 |
ax_top = fig.add_subplot(gs[0, :])
|
|
|
|
| 645 |
}
|
| 646 |
levelt = {
|
| 647 |
11:1,
|
| 648 |
+
14:4,
|
| 649 |
+
|
| 650 |
}
|
| 651 |
|
| 652 |
+
if sport_id != 17:
|
| 653 |
+
fg_api = f'https://www.fangraphs.com/api/leaders/minor-league/data?pos=all&level={levelt[sport_id]}&lg={lg_dict[sport_id]}&stats=pit&qual=0&type=2&team=&season=2024&seasonEnd=2024&org=&ind=0&splitTeam=false'
|
| 654 |
+
response = requests.get(fg_api)
|
| 655 |
+
data = response.json()
|
| 656 |
+
df_fg = pl.DataFrame(data)
|
| 657 |
+
if pitcher_id not in dict_mlb_fg.keys():
|
| 658 |
+
#ax_fv_table.text(x=0.5, y=0.5, s='No Scouting Data', style='italic', ha='center', va='center', fontsize=20, bbox=dict(facecolor='white', alpha=1, pad=10))
|
| 659 |
+
metrics_data = {
|
| 660 |
+
"Pitches": new_player_metrics['pitches'][0],
|
| 661 |
+
"PA": new_player_metrics['pa'][0],
|
| 662 |
+
"BIP": new_player_metrics['bip'][0],
|
| 663 |
+
"HR": f"{new_player_metrics['home_run'][0]:.0f}",
|
| 664 |
+
"K": f"{new_player_metrics['k'][0]:.0f}",
|
| 665 |
+
"BB": f"{new_player_metrics['bb'][0]:.0f}",
|
| 666 |
+
}
|
| 667 |
+
else:
|
| 668 |
+
df_fg_filter = df_fg.filter(pl.col('minormasterid') == dict_mlb_fg[pitcher_id])
|
| 669 |
+
# Metrics data table
|
| 670 |
+
metrics_data = {
|
| 671 |
+
"G": f"{df_fg_filter['G'][0]:.0f}",
|
| 672 |
+
"IP": f"{df_fg_filter['IP'][0]:.1f}",
|
| 673 |
+
"Pitches": f"{new_player_metrics['pitches'][0]:.0f}",
|
| 674 |
+
"PA": f"{df_fg_filter['TBF'][0]:.0f}",
|
| 675 |
+
"BIP": new_player_metrics['bip'][0],
|
| 676 |
+
"ERA": f"{df_fg_filter['ERA'][0]:.2f}",
|
| 677 |
+
"FIP": f"{df_fg_filter['FIP'][0]:.2f}",
|
| 678 |
+
"WHIP": f"{df_fg_filter['WHIP'][0]:.2f}",
|
| 679 |
+
}
|
| 680 |
+
df_table = pd.DataFrame(metrics_data, index=[0])
|
| 681 |
+
ax_table.axis('off')
|
| 682 |
+
table = ax_table.table(cellText=df_table.values, colLabels=df_table.columns, cellLoc='center', loc='bottom', bbox=[0.07, 0, 0.86, 1])
|
| 683 |
+
for key, cell in table.get_celld().items():
|
| 684 |
+
if key[0] == 0:
|
| 685 |
+
cell.set_text_props(fontweight='bold')
|
| 686 |
+
table.auto_set_font_size(False)
|
| 687 |
+
table.set_fontsize(12)
|
| 688 |
+
table.scale(1, 1.5)
|
| 689 |
|
| 690 |
# Additional subplots for spacing
|
| 691 |
ax_top = fig.add_subplot(gs[0, :])
|