James McCool commited on
Commit
2fbdb3f
·
1 Parent(s): 1042879

adding matchups for slate specific filter

Browse files
Files changed (1) hide show
  1. src/streamlit_app.py +10 -3
src/streamlit_app.py CHANGED
@@ -127,6 +127,13 @@ def init_DEM():
127
 
128
  @st.cache_resource(ttl = 600)
129
  def init_macro_tables():
 
 
 
 
 
 
 
130
  team_macro_json = requests.get(NBA_DATA + '?sheet=Team_Macro').json()
131
  team_macro_frame = pd.DataFrame(team_macro_json)
132
  team_macro_frame = team_macro_frame.reset_index(drop=True)
@@ -163,7 +170,7 @@ def init_macro_tables():
163
  team_matchup_frame = team_matchup_frame.reset_index(drop=True)
164
  team_matchup_frame = team_matchup_frame.apply(pd.to_numeric, errors='coerce').fillna(team_matchup_frame)
165
 
166
- return team_off_frame, team_def_frame, team_combo_frame, team_matchup_frame
167
 
168
  def convert_df_to_csv(df):
169
  return df.to_csv().encode('utf-8')
@@ -236,12 +243,12 @@ if selected_tab == 'DEM Matchups':
236
  )
237
 
238
  if selected_tab == 'Team Macro Tables':
239
- team_off_frame, team_def_frame, team_combo_frame, team_matchup_frame = init_macro_tables()
240
  col1, col2 = st.columns([1, 9])
241
  with col1:
242
  if st.button("Reset Data", key='reset2'):
243
  st.cache_data.clear()
244
- team_off_frame, team_def_frame, team_combo_frame, team_matchup_frame = init_macro_tables()
245
  macro_split_var = st.radio("View all teams or just this main slate's matchups?", ('Slate Matchups', 'All'), key='macro_split_var')
246
  if macro_split_var == 'Slate Matchups':
247
  macro_view_var = matchups.Opp.values.tolist()
 
127
 
128
  @st.cache_resource(ttl = 600)
129
  def init_macro_tables():
130
+
131
+ json_matchups = requests.get(NBA_DATA + '?sheet=DEM%20Matchups').json()
132
+ raw_display = pd.DataFrame(json_matchups)
133
+ raw_display = raw_display.reset_index(drop=True)
134
+ matchups = raw_display[raw_display['Var'] != ""]
135
+ matchups_dict = dict(zip(matchups['Team'], matchups['Opp']))
136
+
137
  team_macro_json = requests.get(NBA_DATA + '?sheet=Team_Macro').json()
138
  team_macro_frame = pd.DataFrame(team_macro_json)
139
  team_macro_frame = team_macro_frame.reset_index(drop=True)
 
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, matchups, matchups_dict
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, matchups, matchups_dict = 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, matchups, matchups_dict = init_macro_tables()
252
  macro_split_var = st.radio("View all teams or just this main slate's matchups?", ('Slate Matchups', 'All'), key='macro_split_var')
253
  if macro_split_var == 'Slate Matchups':
254
  macro_view_var = matchups.Opp.values.tolist()