Spaces:
Running
Running
James McCool
commited on
Commit
·
568ebf6
1
Parent(s):
2fbdb3f
Update macro tables to fetch site-specific data and enhance filtering options for main slate matchups
Browse files- src/streamlit_app.py +11 -9
src/streamlit_app.py
CHANGED
|
@@ -128,11 +128,11 @@ def init_DEM():
|
|
| 128 |
@st.cache_resource(ttl = 600)
|
| 129 |
def init_macro_tables():
|
| 130 |
|
| 131 |
-
json_matchups = requests.get(NBA_DATA + '?sheet=
|
| 132 |
raw_display = pd.DataFrame(json_matchups)
|
| 133 |
raw_display = raw_display.reset_index(drop=True)
|
| 134 |
-
|
| 135 |
-
|
| 136 |
|
| 137 |
team_macro_json = requests.get(NBA_DATA + '?sheet=Team_Macro').json()
|
| 138 |
team_macro_frame = pd.DataFrame(team_macro_json)
|
|
@@ -170,7 +170,7 @@ def init_macro_tables():
|
|
| 170 |
team_matchup_frame = team_matchup_frame.reset_index(drop=True)
|
| 171 |
team_matchup_frame = team_matchup_frame.apply(pd.to_numeric, errors='coerce').fillna(team_matchup_frame)
|
| 172 |
|
| 173 |
-
return team_off_frame, team_def_frame, team_combo_frame, team_matchup_frame,
|
| 174 |
|
| 175 |
def convert_df_to_csv(df):
|
| 176 |
return df.to_csv().encode('utf-8')
|
|
@@ -243,15 +243,17 @@ if selected_tab == 'DEM Matchups':
|
|
| 243 |
)
|
| 244 |
|
| 245 |
if selected_tab == 'Team Macro Tables':
|
| 246 |
-
team_off_frame, team_def_frame, team_combo_frame, team_matchup_frame,
|
| 247 |
col1, col2 = st.columns([1, 9])
|
| 248 |
with col1:
|
| 249 |
if st.button("Reset Data", key='reset2'):
|
| 250 |
st.cache_data.clear()
|
| 251 |
-
team_off_frame, team_def_frame, team_combo_frame, team_matchup_frame,
|
| 252 |
-
macro_split_var = st.radio("View all teams or just this main slate's matchups?", ('Slate
|
| 253 |
-
if macro_split_var == 'Slate
|
| 254 |
-
macro_view_var =
|
|
|
|
|
|
|
| 255 |
if macro_split_var == 'All':
|
| 256 |
macro_view_var = team_off_frame.Team.values.tolist()
|
| 257 |
table_var2 = st.selectbox("Select Table", options=['Team Offense', 'Team Defense', 'Team Combo', 'Team Matchups'], key='table_var2')
|
|
|
|
| 128 |
@st.cache_resource(ttl = 600)
|
| 129 |
def init_macro_tables():
|
| 130 |
|
| 131 |
+
json_matchups = requests.get(NBA_DATA + '?sheet=Site_Info').json()
|
| 132 |
raw_display = pd.DataFrame(json_matchups)
|
| 133 |
raw_display = raw_display.reset_index(drop=True)
|
| 134 |
+
dk_main_slate = raw_display['DK Main'].values.tolist()
|
| 135 |
+
fd_main_slate = raw_display['FD Main'].values.tolist()
|
| 136 |
|
| 137 |
team_macro_json = requests.get(NBA_DATA + '?sheet=Team_Macro').json()
|
| 138 |
team_macro_frame = pd.DataFrame(team_macro_json)
|
|
|
|
| 170 |
team_matchup_frame = team_matchup_frame.reset_index(drop=True)
|
| 171 |
team_matchup_frame = team_matchup_frame.apply(pd.to_numeric, errors='coerce').fillna(team_matchup_frame)
|
| 172 |
|
| 173 |
+
return team_off_frame, team_def_frame, team_combo_frame, team_matchup_frame, dk_main_slate, fd_main_slate
|
| 174 |
|
| 175 |
def convert_df_to_csv(df):
|
| 176 |
return df.to_csv().encode('utf-8')
|
|
|
|
| 243 |
)
|
| 244 |
|
| 245 |
if selected_tab == 'Team Macro Tables':
|
| 246 |
+
team_off_frame, team_def_frame, team_combo_frame, team_matchup_frame, dk_main_slate, fd_main_slate = init_macro_tables()
|
| 247 |
col1, col2 = st.columns([1, 9])
|
| 248 |
with col1:
|
| 249 |
if st.button("Reset Data", key='reset2'):
|
| 250 |
st.cache_data.clear()
|
| 251 |
+
team_off_frame, team_def_frame, team_combo_frame, team_matchup_frame, dk_main_slate, fd_main_slate = init_macro_tables()
|
| 252 |
+
macro_split_var = st.radio("View all teams or just this main slate's matchups?", ('DK Main Slate', 'FD Main Slate', 'All'), key='macro_split_var')
|
| 253 |
+
if macro_split_var == 'DK Main Slate':
|
| 254 |
+
macro_view_var = dk_main_slate
|
| 255 |
+
if macro_split_var == 'FD Main Slate':
|
| 256 |
+
macro_view_var = fd_main_slate
|
| 257 |
if macro_split_var == 'All':
|
| 258 |
macro_view_var = team_off_frame.Team.values.tolist()
|
| 259 |
table_var2 = st.selectbox("Select Table", options=['Team Offense', 'Team Defense', 'Team Combo', 'Team Matchups'], key='table_var2')
|