Update app.py
Browse files
app.py
CHANGED
|
@@ -132,7 +132,7 @@ level_dict_file = {'1':'mlb',
|
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
-
year_list = [
|
| 136 |
|
| 137 |
|
| 138 |
from shiny import App, reactive, ui, render
|
|
@@ -210,26 +210,26 @@ def server(input, output, session):
|
|
| 210 |
def player_select_ui():
|
| 211 |
if input.tabset() == "Batter Summary":
|
| 212 |
#Get the list of pitchers for the selected level and season
|
| 213 |
-
df_pitcher_info = scrape.get_players(sport_id=int(input.level_input()), season=int(input.year_input())).filter(
|
| 214 |
-
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
# Create a dictionary of pitcher IDs and names
|
| 219 |
-
batter_dict_pos = dict(zip(df_pitcher_info['player_id'], df_pitcher_info['position']))
|
| 220 |
|
| 221 |
year = int(input.year_input())
|
| 222 |
sport_id = int(input.level_input())
|
| 223 |
batter_summary = pl.read_parquet(f"hf://datasets/TJStatsApps/mlb_data/summary/batter_summary_{level_dict_file[str(sport_id)]}_{year}_spring.parquet").sort('batter_name',descending=False)
|
| 224 |
# Map elements in Polars DataFrame from a dictionary
|
| 225 |
-
batter_summary = batter_summary.with_columns(
|
| 226 |
-
pl.col("batter_id").map_elements(lambda x: batter_dict_pos.get(x, x)).alias("position")
|
| 227 |
-
)
|
| 228 |
|
| 229 |
|
| 230 |
-
batter_dict_pos = dict(zip(batter_summary['batter_id'], batter_summary['batter_name']))
|
| 231 |
# Create a dictionary of pitcher IDs and names
|
| 232 |
-
batter_dict = dict(zip(batter_summary['batter_id'], batter_summary['batter_name'] + ' - ' + batter_summary['
|
| 233 |
|
| 234 |
# Return a select input for choosing a pitcher
|
| 235 |
return ui.input_select("batter_id", "Select Batter", batter_dict, selectize=True)
|
|
|
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
+
year_list = [2024]
|
| 136 |
|
| 137 |
|
| 138 |
from shiny import App, reactive, ui, render
|
|
|
|
| 210 |
def player_select_ui():
|
| 211 |
if input.tabset() == "Batter Summary":
|
| 212 |
#Get the list of pitchers for the selected level and season
|
| 213 |
+
# df_pitcher_info = scrape.get_players(sport_id=int(input.level_input()), season=int(input.year_input())).filter(
|
| 214 |
+
# ~pl.col("position").is_in(['P'])).sort("name")
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
# Create a dictionary of pitcher IDs and names
|
| 219 |
+
# batter_dict_pos = dict(zip(df_pitcher_info['player_id'], df_pitcher_info['position']))
|
| 220 |
|
| 221 |
year = int(input.year_input())
|
| 222 |
sport_id = int(input.level_input())
|
| 223 |
batter_summary = pl.read_parquet(f"hf://datasets/TJStatsApps/mlb_data/summary/batter_summary_{level_dict_file[str(sport_id)]}_{year}_spring.parquet").sort('batter_name',descending=False)
|
| 224 |
# Map elements in Polars DataFrame from a dictionary
|
| 225 |
+
# batter_summary = batter_summary.with_columns(
|
| 226 |
+
# pl.col("batter_id").map_elements(lambda x: batter_dict_pos.get(x, x)).alias("position")
|
| 227 |
+
# )
|
| 228 |
|
| 229 |
|
| 230 |
+
# batter_dict_pos = dict(zip(batter_summary['batter_id'], batter_summary['batter_name']))
|
| 231 |
# Create a dictionary of pitcher IDs and names
|
| 232 |
+
batter_dict = dict(zip(batter_summary['batter_id'], batter_summary['batter_name'] + ' - ' + batter_summary['batter_id']))
|
| 233 |
|
| 234 |
# Return a select input for choosing a pitcher
|
| 235 |
return ui.input_select("batter_id", "Select Batter", batter_dict, selectize=True)
|