Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -39,8 +39,9 @@ gc2 = gspread.service_account_from_dict(credentials2)
|
|
| 39 |
|
| 40 |
st.set_page_config(layout="wide")
|
| 41 |
|
| 42 |
-
game_format = {'
|
| 43 |
-
'
|
|
|
|
| 44 |
|
| 45 |
mlb_model_link = 'https://docs.google.com/spreadsheets/d/1f42Ergav8K1VsOLOK9MUn7DM_MLMvv4GR2Fy7EfnZTc/edit#gid=1769627309'
|
| 46 |
|
|
@@ -52,7 +53,8 @@ def load_init():
|
|
| 52 |
sh = gc2.open_by_url(mlb_model_link)
|
| 53 |
worksheet = sh.worksheet('Ballpark_stats')
|
| 54 |
raw_display = pd.DataFrame(worksheet.get_all_records())
|
| 55 |
-
overall_stats = raw_display
|
|
|
|
| 56 |
raw_numbers = raw_display[['Stadium', 'Split', 'PA', 'Hits', 'Singles', 'Doubles', 'Homeruns', 'K_rate', 'Walk_rate', 'xBA_avg', 'xSLG_avg', 'xwOBA_avg']]
|
| 57 |
pa_numbers = raw_display[['Stadium', 'Split', 'PA', 'Hits/PA', 'Singles/PA', 'Doubles/PA', 'Homeruns/PA', 'K_rate', 'Walk_rate', 'xBA_avg', 'xSLG_avg', 'xwOBA_avg']]
|
| 58 |
boosts = raw_display[['Stadium', 'Split', 'PA', 'Hits_boost', 'Singles_boost', 'Doubles_boost', 'Homeruns_boost', 'K_rate_boost', 'Walk_rate_boost', 'xBA_avg_boost', 'xSLG_avg_boost', 'xwOBA_avg_boost']]
|
|
@@ -107,7 +109,7 @@ with hold_container:
|
|
| 107 |
elif split_var1 == 'RHH':
|
| 108 |
final_Proj = final_Proj[final_Proj['Split'] == 'RHH']
|
| 109 |
final_Proj = final_Proj.sort_values(by='xwOBA_avg_boost', ascending=False)
|
| 110 |
-
st.dataframe(final_Proj.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), height=1000, use_container_width = True)
|
| 111 |
|
| 112 |
st.download_button(
|
| 113 |
label="Export Tables",
|
|
|
|
| 39 |
|
| 40 |
st.set_page_config(layout="wide")
|
| 41 |
|
| 42 |
+
game_format = {'K_rate': '{:.2%}', 'Walk_rate': '{:.2%}', 'xBA_avg': '{:.2%}', 'xSLG_avg': '{:.2%}', 'xwOBA_avg': '{:.2%}', 'Hits_boost': '{:.2%}',
|
| 43 |
+
'Singles_boost': '{:.2%}', 'Doubles_boost': '{:.2%}', 'Homeruns_boost': '{:.2%}', 'K_rate_boost': '{:.2%}', 'Walk_rate_boost': '{:.2%}',
|
| 44 |
+
'xBA_avg_boost': '{:.2%}', 'xSLG_avg_boost': '{:.2%}', 'xwOBA_avg_boost': '{:.2%}'}
|
| 45 |
|
| 46 |
mlb_model_link = 'https://docs.google.com/spreadsheets/d/1f42Ergav8K1VsOLOK9MUn7DM_MLMvv4GR2Fy7EfnZTc/edit#gid=1769627309'
|
| 47 |
|
|
|
|
| 53 |
sh = gc2.open_by_url(mlb_model_link)
|
| 54 |
worksheet = sh.worksheet('Ballpark_stats')
|
| 55 |
raw_display = pd.DataFrame(worksheet.get_all_records())
|
| 56 |
+
overall_stats = raw_display[['Stadium', 'Split', 'PA', 'Hits', 'Singles', 'Doubles', 'Homeruns', 'K_rate', 'Walk_rate', 'xBA_avg', 'xSLG_avg', 'xwOBA_avg', 'Hits_boost',
|
| 57 |
+
'Singles_boost', 'Doubles_boost', 'Homeruns_boost', 'K_rate_boost', 'Walk_rate_boost', 'xBA_avg_boost', 'xSLG_avg_boost', 'xwOBA_avg_boost']]
|
| 58 |
raw_numbers = raw_display[['Stadium', 'Split', 'PA', 'Hits', 'Singles', 'Doubles', 'Homeruns', 'K_rate', 'Walk_rate', 'xBA_avg', 'xSLG_avg', 'xwOBA_avg']]
|
| 59 |
pa_numbers = raw_display[['Stadium', 'Split', 'PA', 'Hits/PA', 'Singles/PA', 'Doubles/PA', 'Homeruns/PA', 'K_rate', 'Walk_rate', 'xBA_avg', 'xSLG_avg', 'xwOBA_avg']]
|
| 60 |
boosts = raw_display[['Stadium', 'Split', 'PA', 'Hits_boost', 'Singles_boost', 'Doubles_boost', 'Homeruns_boost', 'K_rate_boost', 'Walk_rate_boost', 'xBA_avg_boost', 'xSLG_avg_boost', 'xwOBA_avg_boost']]
|
|
|
|
| 109 |
elif split_var1 == 'RHH':
|
| 110 |
final_Proj = final_Proj[final_Proj['Split'] == 'RHH']
|
| 111 |
final_Proj = final_Proj.sort_values(by='xwOBA_avg_boost', ascending=False)
|
| 112 |
+
st.dataframe(final_Proj.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(game_format, precision=2), height=1000, use_container_width = True)
|
| 113 |
|
| 114 |
st.download_button(
|
| 115 |
label="Export Tables",
|