Update app.py
Browse files
app.py
CHANGED
@@ -110,7 +110,14 @@ app_ui = ui.page_fluid(
|
|
110 |
|
111 |
output_tabulator("table_stuff_all")
|
112 |
|
113 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
|
115 |
)
|
116 |
)
|
@@ -972,5 +979,80 @@ def server(input, output, session):
|
|
972 |
)
|
973 |
|
974 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
975 |
|
976 |
app = App(app_ui, server)
|
|
|
110 |
|
111 |
output_tabulator("table_stuff_all")
|
112 |
|
113 |
+
),
|
114 |
+
ui.nav("tjStuff+ Team",
|
115 |
+
|
116 |
+
ui.row(
|
117 |
+
ui.column(2,
|
118 |
+
)),
|
119 |
+
output_tabulator("table_tjstuff_team")
|
120 |
+
),
|
121 |
|
122 |
)
|
123 |
)
|
|
|
979 |
)
|
980 |
|
981 |
|
982 |
+
@output
|
983 |
+
@render_tabulator
|
984 |
+
@reactive.event(input.refresh)
|
985 |
+
def table_tjstuff_team():
|
986 |
+
|
987 |
+
df_spring = spring_data()
|
988 |
+
|
989 |
+
# df_year_old = stuff_apply.stuff_apply(fe.feature_engineering(pl.concat([df_mlb,df_aaa,df_a,df_afl])))
|
990 |
+
# df_year_2old = stuff_apply.stuff_apply(fe.feature_engineering(pl.concat([df_mlb_2023])))
|
991 |
+
df_spring_stuff = stuff_apply.stuff_apply(fe.feature_engineering(df_spring))
|
992 |
+
|
993 |
+
|
994 |
+
|
995 |
+
import polars as pl
|
996 |
+
|
997 |
+
|
998 |
+
|
999 |
+
df_spring_group = df_spring_stuff.group_by(['pitcher_team']).agg([
|
1000 |
+
pl.col('start_speed').count().alias('count'),
|
1001 |
+
pl.col('start_speed').mean().alias('start_speed'),
|
1002 |
+
pl.col('start_speed').max().alias('max_start_speed'),
|
1003 |
+
pl.col('ivb').mean().alias('ivb'),
|
1004 |
+
pl.col('hb').mean().alias('hb'),
|
1005 |
+
pl.col('release_pos_z').mean().alias('release_pos_z'),
|
1006 |
+
pl.col('release_pos_x').mean().alias('release_pos_x'),
|
1007 |
+
pl.col('extension').mean().alias('extension'),
|
1008 |
+
pl.col('tj_stuff_plus').mean().round(0).alias('tj_stuff_plus'),
|
1009 |
+
(pl.col('start_speed').filter(pl.col('batter_hand')=='L').count()).alias('rhh_count'),
|
1010 |
+
(pl.col('start_speed').filter(pl.col('batter_hand')=='R').count()).alias('lhh_count')
|
1011 |
+
])
|
1012 |
+
|
1013 |
+
|
1014 |
+
|
1015 |
+
columns = [
|
1016 |
+
# { "title": "Pitcher Name", "field": "pitcher_name", "width": 250, "headerFilter":"input" ,"frozen":True,},
|
1017 |
+
{ "title": "Team", "field": "pitcher_team", "width": 250, "headerFilter":"input" ,"frozen":True,},
|
1018 |
+
# { "title": "Pitch Type", "field": "pitch_type", "width": 125, "headerFilter":"input" ,"frozen":True,},
|
1019 |
+
# { "title": "New?", "field": "new_pitch", "width": 125, "headerFilter":"input" ,"frozen":False,},
|
1020 |
+
{ "title": "Pitches", "field": "count", "width": 250 , "headerFilter":"input"},
|
1021 |
+
# { "title": "Pitch%", "field": "pitch_percent_formatted", "width": 100, "headerFilter":"input"},
|
1022 |
+
# { "title": "RHH%", "field": "rhh_percent_formatted", "width": 90, "headerFilter":"input"},
|
1023 |
+
# { "title": "LHH%", "field": "lhh_percent_formatted", "width": 90, "headerFilter":"input"},
|
1024 |
+
# { "title": "Velocity", "field": "start_speed_formatted", "width": 100, "headerFilter":"input", "formatter":"textarea" },
|
1025 |
+
# { "title": "Max Velo", "field": "max_start_speed_formatted", "width": 100, "headerFilter":"input", "formatter":"textarea" },
|
1026 |
+
# { "title": "iVB", "field": "ivb_formatted", "width": 80, "headerFilter":"input", "formatter":"textarea" },
|
1027 |
+
# { "title": "HB", "field": "hb_formatted", "width": 80, "headerFilter":"input", "formatter":"textarea" },
|
1028 |
+
# { "title": "RelH", "field": "release_pos_z_formatted", "width": 80, "headerFilter":"input", "formatter":"textarea" },
|
1029 |
+
# { "title": "RelS", "field": "release_pos_x_formatted", "width": 80, "headerFilter":"input", "formatter":"textarea" },
|
1030 |
+
# { "title": "Extension", "field": "extension_formatted", "width": 125, "headerFilter":"input", "formatter":"textarea" },
|
1031 |
+
{ "title": "tjStuff+", "field": "tj_stuff_plus", "width": 250, "headerFilter":"input", "formatter":"textarea" },
|
1032 |
+
# { "title": "2024 tjStuff+", "field": "tj_stuff_plus_old", "width": 100, "headerFilter":"input", "formatter":"textarea" },
|
1033 |
+
# { "title": "Δ", "field": "tj_stuff_plus_diff", "width": 100, "headerFilter":"input", "formatter":"textarea" }
|
1034 |
+
]
|
1035 |
+
|
1036 |
+
df_merge = df_spring_group.clone()
|
1037 |
+
|
1038 |
+
df_plot = df_merge.sort(['pitcher_team','count'],descending=True).to_pandas()
|
1039 |
+
|
1040 |
+
# team_dict = dict(zip(df_spring['pitcher_id'],df_spring['pitcher_team']))
|
1041 |
+
# df_plot['pitcher_team'] = df_plot['pitcher_id'].map(team_dict)
|
1042 |
+
|
1043 |
+
|
1044 |
+
|
1045 |
+
return Tabulator(
|
1046 |
+
df_plot,
|
1047 |
+
|
1048 |
+
table_options=TableOptions(
|
1049 |
+
height=750,
|
1050 |
+
|
1051 |
+
columns=columns,
|
1052 |
+
)
|
1053 |
+
)
|
1054 |
+
|
1055 |
+
|
1056 |
+
|
1057 |
|
1058 |
app = App(app_ui, server)
|