Spaces:
Running
Running
James McCool
commited on
Commit
·
8ade7a1
1
Parent(s):
36150d4
adding some styling, clean up
Browse files- src/streamlit_app.py +8 -1
src/streamlit_app.py
CHANGED
|
@@ -17,6 +17,8 @@ percentages_format = {'Pts% Boost': '{:.2%}', 'Reb% Boost': '{:.2%}', 'Ast% Boos
|
|
| 17 |
'Stl Boost%': '{:.2%}', 'Blk Boost%': '{:.2%}', 'TOV Boost%': '{:.2%}', 'FPPM Boost': '{:.2%}',
|
| 18 |
'Team FPPM Boost': '{:.2%}'}
|
| 19 |
|
|
|
|
|
|
|
| 20 |
st.markdown("""
|
| 21 |
<style>
|
| 22 |
/* Tab styling */
|
|
@@ -125,20 +127,25 @@ def init_macro_tables():
|
|
| 125 |
team_macro_json = requests.get(NBA_DATA + '?sheet=Team_Macro').json()
|
| 126 |
team_macro_frame = pd.DataFrame(team_macro_json)
|
| 127 |
team_macro_frame = team_macro_frame.reset_index(drop=True)
|
|
|
|
| 128 |
|
| 129 |
team_off_frame = team_macro_frame[team_macro_frame['Data'] == 'Off']
|
| 130 |
team_off_frame = team_off_frame.reset_index(drop=True)
|
|
|
|
| 131 |
|
| 132 |
team_def_frame = team_macro_frame[team_macro_frame['Data'] == 'Def']
|
| 133 |
team_def_frame = team_def_frame.reset_index(drop=True)
|
|
|
|
| 134 |
|
| 135 |
team_combo_json = requests.get(NBA_DATA + '?sheet=Team%20Combo%20Data').json()
|
| 136 |
team_combo_frame = pd.DataFrame(team_combo_json)
|
| 137 |
team_combo_frame = team_combo_frame.reset_index(drop=True)
|
|
|
|
| 138 |
|
| 139 |
team_matchup_json = requests.get(NBA_DATA + '?sheet=Team%20Matchups').json()
|
| 140 |
team_matchup_frame = pd.DataFrame(team_matchup_json)
|
| 141 |
team_matchup_frame = team_matchup_frame.reset_index(drop=True)
|
|
|
|
| 142 |
|
| 143 |
return team_off_frame, team_def_frame, team_combo_frame, team_matchup_frame
|
| 144 |
|
|
@@ -229,7 +236,7 @@ if selected_tab == 'Team Macro Tables':
|
|
| 229 |
team_macro_display = team_combo_frame
|
| 230 |
elif table_var2 == 'Team Matchups':
|
| 231 |
team_macro_display = team_matchup_frame
|
| 232 |
-
st.dataframe(team_macro_display.set_index('Team').style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
| 233 |
st.download_button(
|
| 234 |
label="Export Table Data",
|
| 235 |
data=convert_df_to_csv(team_macro_display),
|
|
|
|
| 17 |
'Stl Boost%': '{:.2%}', 'Blk Boost%': '{:.2%}', 'TOV Boost%': '{:.2%}', 'FPPM Boost': '{:.2%}',
|
| 18 |
'Team FPPM Boost': '{:.2%}'}
|
| 19 |
|
| 20 |
+
team_macro_format = {'FGM%': '{:.2%}', 'FG3M%': '{:.2%}', 'FTM%': '{:.2%}'}
|
| 21 |
+
|
| 22 |
st.markdown("""
|
| 23 |
<style>
|
| 24 |
/* Tab styling */
|
|
|
|
| 127 |
team_macro_json = requests.get(NBA_DATA + '?sheet=Team_Macro').json()
|
| 128 |
team_macro_frame = pd.DataFrame(team_macro_json)
|
| 129 |
team_macro_frame = team_macro_frame.reset_index(drop=True)
|
| 130 |
+
team_macro_frame = team_macro_frame[team_macro_frame['Team'] != ""]
|
| 131 |
|
| 132 |
team_off_frame = team_macro_frame[team_macro_frame['Data'] == 'Off']
|
| 133 |
team_off_frame = team_off_frame.reset_index(drop=True)
|
| 134 |
+
team_off_frame = team_off_frame.apply(pd.to_numeric, errors='coerce').fillna(team_off_frame)
|
| 135 |
|
| 136 |
team_def_frame = team_macro_frame[team_macro_frame['Data'] == 'Def']
|
| 137 |
team_def_frame = team_def_frame.reset_index(drop=True)
|
| 138 |
+
team_def_frame = team_def_frame.apply(pd.to_numeric, errors='coerce').fillna(team_def_frame)
|
| 139 |
|
| 140 |
team_combo_json = requests.get(NBA_DATA + '?sheet=Team%20Combo%20Data').json()
|
| 141 |
team_combo_frame = pd.DataFrame(team_combo_json)
|
| 142 |
team_combo_frame = team_combo_frame.reset_index(drop=True)
|
| 143 |
+
team_combo_frame = team_combo_frame.apply(pd.to_numeric, errors='coerce').fillna(team_combo_frame)
|
| 144 |
|
| 145 |
team_matchup_json = requests.get(NBA_DATA + '?sheet=Team%20Matchups').json()
|
| 146 |
team_matchup_frame = pd.DataFrame(team_matchup_json)
|
| 147 |
team_matchup_frame = team_matchup_frame.reset_index(drop=True)
|
| 148 |
+
team_matchup_frame = team_matchup_frame.apply(pd.to_numeric, errors='coerce').fillna(team_matchup_frame)
|
| 149 |
|
| 150 |
return team_off_frame, team_def_frame, team_combo_frame, team_matchup_frame
|
| 151 |
|
|
|
|
| 236 |
team_macro_display = team_combo_frame
|
| 237 |
elif table_var2 == 'Team Matchups':
|
| 238 |
team_macro_display = team_matchup_frame
|
| 239 |
+
st.dataframe(team_macro_display.set_index('Team').style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(team_macro_format, precision=2), use_container_width = True)
|
| 240 |
st.download_button(
|
| 241 |
label="Export Table Data",
|
| 242 |
data=convert_df_to_csv(team_macro_display),
|