nesticot commited on
Commit
94161b7
·
verified ·
1 Parent(s): 7f24e2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +22 -2
app.py CHANGED
@@ -279,8 +279,28 @@ def server(input, output, session):
279
  # Download handler for CSV
280
  @session.download(filename="data.csv")
281
  def download_data():
282
- # Get the current dataset and save it to CSV
283
- return cached_data().write_csv('data.csv')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
 
285
 
286
 
 
279
  # Download handler for CSV
280
  @session.download(filename="data.csv")
281
  def download_data():
282
+ year_input = int(input.year_input())
283
+ sport_id = int(input.level_input())
284
+ player_input = int(input.pitcher_id())
285
+ start_date = str(input.date_id()[0])
286
+ end_date = str(input.date_id()[1])
287
+ # Simulate an expensive data operation
288
+ game_list = scrape.get_player_games_list(sport_id = sport_id,
289
+ season = year_input,
290
+ player_id = player_input,
291
+ start_date = start_date,
292
+ end_date = end_date)
293
+
294
+ data_list = scrape.get_data(game_list_input = game_list[:])
295
+ df = (stuff_apply.stuff_apply(fe.feature_engineering(update.update(scrape.get_data_df(data_list = data_list).filter(
296
+ (pl.col("pitcher_id") == player_input)&
297
+ (pl.col("is_pitch") == True)&
298
+ (pl.col('batter_hand').is_in(split_dict_hand[input.split_id()]))
299
+
300
+ )))).with_columns(
301
+ pl.col('pitch_type').count().over('pitch_type').alias('pitch_count')
302
+ ))
303
+ return df.write_csv()
304
 
305
 
306