Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -52,7 +52,7 @@ def init_baselines():
|
|
52 |
raw_display = pd.DataFrame(list(cursor))
|
53 |
hitter_gamelog_table = raw_display[['NameASCII', 'Team', 'Date', 'G', 'AB', 'PA', 'H', '1B', '2B', '3B', 'HR', 'R', 'RBI', 'BB', 'IBB', 'SO', 'HBP', 'SF', 'SH',
|
54 |
'GDP', 'SB', 'CS', 'AVG', 'SLG', 'wRC+', 'LD%', 'GB%', 'FB%', 'Hard%', 'Barrels', 'Barrel%']]
|
55 |
-
|
56 |
data_cols = hitter_gamelog_table.columns.drop(['NameASCII', 'Team', 'Date'])
|
57 |
hitter_gamelog_table[data_cols] = hitter_gamelog_table[data_cols].apply(pd.to_numeric, errors='coerce')
|
58 |
|
@@ -70,6 +70,7 @@ def init_baselines():
|
|
70 |
'vSL (sc)', 'vCU (sc)', 'vKC (sc)', 'vEP (sc)', 'vCH (sc)', 'vSC (sc)', 'vKN (sc)']]
|
71 |
|
72 |
pitcher_gamelog_table.replace("", np.nan, inplace=True)
|
|
|
73 |
data_cols = pitcher_gamelog_table.columns.drop(['NameASCII', 'Team', 'Date'])
|
74 |
pitcher_gamelog_table[data_cols] = pitcher_gamelog_table[data_cols].apply(pd.to_numeric, errors='coerce')
|
75 |
|
@@ -410,8 +411,8 @@ with tab2:
|
|
410 |
if high_date is not None:
|
411 |
high_date = pd.to_datetime(high_date).date()
|
412 |
elif split_var3 == 'All':
|
413 |
-
low_date =
|
414 |
-
high_date =
|
415 |
|
416 |
split_var4 = st.radio("Would you like to view all players or specific ones?", ('All', 'Specific Players'), key='sp_split_var4')
|
417 |
|
@@ -421,7 +422,7 @@ with tab2:
|
|
421 |
player_var1 = total_hitters
|
422 |
|
423 |
with col2:
|
424 |
-
working_data =
|
425 |
if split_var1 == 'Season Logs':
|
426 |
choose_cols = st.container()
|
427 |
with choose_cols:
|
@@ -432,7 +433,7 @@ with tab2:
|
|
432 |
working_data = working_data[working_data['Date'] <= high_date]
|
433 |
working_data = working_data[working_data['Team'].isin(team_var1)]
|
434 |
working_data = working_data[working_data['Player'].isin(player_var1)]
|
435 |
-
season_long_table =
|
436 |
season_long_table = season_long_table.set_index('Player')
|
437 |
season_long_table_disp = season_long_table.reindex(disp_stats,axis="columns")
|
438 |
display.dataframe(season_long_table_disp.style.format(precision=2), height=750, use_container_width = True)
|
|
|
52 |
raw_display = pd.DataFrame(list(cursor))
|
53 |
hitter_gamelog_table = raw_display[['NameASCII', 'Team', 'Date', 'G', 'AB', 'PA', 'H', '1B', '2B', '3B', 'HR', 'R', 'RBI', 'BB', 'IBB', 'SO', 'HBP', 'SF', 'SH',
|
54 |
'GDP', 'SB', 'CS', 'AVG', 'SLG', 'wRC+', 'LD%', 'GB%', 'FB%', 'Hard%', 'Barrels', 'Barrel%']]
|
55 |
+
hitter_gamelog_table['Date'] = pd.to_datetime(hitter_gamelog_table['Date'].dt.date)
|
56 |
data_cols = hitter_gamelog_table.columns.drop(['NameASCII', 'Team', 'Date'])
|
57 |
hitter_gamelog_table[data_cols] = hitter_gamelog_table[data_cols].apply(pd.to_numeric, errors='coerce')
|
58 |
|
|
|
70 |
'vSL (sc)', 'vCU (sc)', 'vKC (sc)', 'vEP (sc)', 'vCH (sc)', 'vSC (sc)', 'vKN (sc)']]
|
71 |
|
72 |
pitcher_gamelog_table.replace("", np.nan, inplace=True)
|
73 |
+
pitcher_gamelog_table['Date'] = pd.to_datetime(pitcher_gamelog_table['Date'].dt.date)
|
74 |
data_cols = pitcher_gamelog_table.columns.drop(['NameASCII', 'Team', 'Date'])
|
75 |
pitcher_gamelog_table[data_cols] = pitcher_gamelog_table[data_cols].apply(pd.to_numeric, errors='coerce')
|
76 |
|
|
|
411 |
if high_date is not None:
|
412 |
high_date = pd.to_datetime(high_date).date()
|
413 |
elif split_var3 == 'All':
|
414 |
+
low_date = pitcher_gamelog_table['Date'].min()
|
415 |
+
high_date = pitcher_gamelog_table['Date'].max()
|
416 |
|
417 |
split_var4 = st.radio("Would you like to view all players or specific ones?", ('All', 'Specific Players'), key='sp_split_var4')
|
418 |
|
|
|
422 |
player_var1 = total_hitters
|
423 |
|
424 |
with col2:
|
425 |
+
working_data = pitcher_gamelog_table
|
426 |
if split_var1 == 'Season Logs':
|
427 |
choose_cols = st.container()
|
428 |
with choose_cols:
|
|
|
433 |
working_data = working_data[working_data['Date'] <= high_date]
|
434 |
working_data = working_data[working_data['Team'].isin(team_var1)]
|
435 |
working_data = working_data[working_data['Player'].isin(player_var1)]
|
436 |
+
season_long_table = pitcher_seasonlong_build(working_data)
|
437 |
season_long_table = season_long_table.set_index('Player')
|
438 |
season_long_table_disp = season_long_table.reindex(disp_stats,axis="columns")
|
439 |
display.dataframe(season_long_table_disp.style.format(precision=2), height=750, use_container_width = True)
|