nesticot commited on
Commit
8bb9fa3
·
verified ·
1 Parent(s): 94161b7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -22
app.py CHANGED
@@ -279,28 +279,12 @@ def server(input, output, session):
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
 
 
279
  # Download handler for CSV
280
  @session.download(filename="data.csv")
281
  def download_data():
282
+ # Create a string buffer
283
+ buffer = StringIO()
284
+ # Write the DataFrame to the buffer
285
+ cached_data().write_csv(buffer)
286
+ # Get the string value and return it
287
+ return buffer.getvalue()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
288
 
289
 
290