nesticot commited on
Commit
d126ab8
·
verified ·
1 Parent(s): a4cb42a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py CHANGED
@@ -103,6 +103,18 @@ df_image = pd.DataFrame(mlb_teams)
103
  image_dict = df_image.set_index('team')['logo_url'].to_dict()
104
  image_dict_flip = df_image.set_index('logo_url')['team'].to_dict()
105
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  from shiny import App, reactive, ui, render
107
  from shiny.ui import h2, tags
108
 
@@ -148,6 +160,8 @@ app_ui = ui.page_sidebar(
148
  ui.output_text("status"),
149
  ui.output_plot('plot', width='2100px', height='2100px')
150
  ),
 
 
151
  )
152
  )
153
 
@@ -347,6 +361,32 @@ def server(input, output, session):
347
  fig.subplots_adjust(left=0.01, right=0.99, top=0.99, bottom=0.01)
348
 
349
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
350
 
351
 
352
  app = App(app_ui, server)
 
103
  image_dict = df_image.set_index('team')['logo_url'].to_dict()
104
  image_dict_flip = df_image.set_index('logo_url')['team'].to_dict()
105
 
106
+
107
+
108
+ # # Define the features to be used for training
109
+ # features_table = ['start_speed',
110
+ # 'spin_rate',
111
+ # 'extension',
112
+ # 'ivb',
113
+ # 'hb',
114
+ # 'x0',
115
+ # 'z0',
116
+ # 'tj_stuff_plus']
117
+
118
  from shiny import App, reactive, ui, render
119
  from shiny.ui import h2, tags
120
 
 
160
  ui.output_text("status"),
161
  ui.output_plot('plot', width='2100px', height='2100px')
162
  ),
163
+ ui.nav_panel("Summary Table",
164
+ ui.output_data_frame("grid"))
165
  )
166
  )
167
 
 
361
  fig.subplots_adjust(left=0.01, right=0.99, top=0.99, bottom=0.01)
362
 
363
 
364
+ @output
365
+ @render.data_frame
366
+ @reactive.event(input.generate_plot, ignore_none=False)
367
+ def grid():
368
+
369
+ df = cached_data()
370
+ df = df.clone()
371
+ features_table = ['start_speed',
372
+ 'spin_rate',
373
+ 'extension',
374
+ 'az',
375
+ 'ax',
376
+ 'x0',
377
+ 'z0']
378
+
379
+ selection = [['pitcher_id','pitcher_name','batter_id','batter_name','pitcher_hand',
380
+ 'batter_hand','balls','strikes','play_code','event_type','pitch_type','vaa','haa']+features_table+['tj_stuff_plus']]
381
+
382
+
383
+ return render.DataGrid(
384
+ df.select(selection).round(1),
385
+ row_selection_mode='multiple',
386
+ height=None,
387
+ width='fit-content',
388
+ filters=True,
389
+ )
390
 
391
 
392
  app = App(app_ui, server)