Multichem commited on
Commit
ab079c4
·
verified ·
1 Parent(s): 29f62e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +64 -63
app.py CHANGED
@@ -115,73 +115,17 @@ def convert_df_to_csv(df):
115
  rb_search, wr_search, rb_season, wr_season, wr_matchups, macro_data, trending_data = pull_baselines()
116
  pos_list = ['RB', 'WR', 'TE']
117
 
118
- tab1, tab2 = st.tabs(["Season Long Research", "Slate Specific"])
119
  with tab1:
120
  col1, col2 = st.columns([1, 8])
121
 
122
- with col1:
123
- if st.button("Load/Reset Data", key='reset1'):
124
- st.cache_data.clear()
125
- rb_search, wr_search, rb_season, wr_season, wr_matchups, macro_data, trending_data = pull_baselines()
126
- stat_type_var1 = st.radio("What table are you loading?", ('Macro Table', 'RB Usage (Weekly)', 'WR/TE Usage (Weekly)', 'RB Usage (Season)', 'WR/TE Usage (Season)'), key='stat_type_var1')
127
- split_var1 = st.radio("Are you running the the whole league or certain teams?", ('All Teams', 'Specific Teams'), key='split_var1')
128
- pos_split1 = st.radio("Are you viewing all positions or specific positions?", ('All Positions', 'Specific Positions'), key='pos_split1')
129
- if pos_split1 == 'Specific Positions':
130
- pos_var1 = st.multiselect('What Positions would you like to view?', options = ['RB', 'WR', 'TE'])
131
- elif pos_split1 == 'All Positions':
132
- pos_var1 = pos_list
133
- if split_var1 == 'Specific Teams':
134
- team_var1 = st.multiselect('Which teams would you like to include in the Table?', options = rb_search['Team-Season'].unique(), key='team_var1')
135
- elif split_var1 == 'All Teams':
136
- team_var1 = rb_search['Team-Season'].unique().tolist()
137
- if stat_type_var1 == 'Macro Table':
138
- table_instance = macro_data
139
- table_instance = table_instance.set_index('Team')
140
- elif stat_type_var1 == 'RB Usage (Weekly)':
141
- table_instance = rb_search
142
- table_instance = table_instance[table_instance['Team-Season'].isin(team_var1)]
143
- table_instance = table_instance[table_instance['Position'].isin(pos_var1)]
144
- elif stat_type_var1 == 'WR/TE Usage (Weekly)':
145
- table_instance = wr_search
146
- table_instance = table_instance[table_instance['Team-Season'].isin(team_var1)]
147
- table_instance = table_instance[table_instance['Position'].isin(pos_var1)]
148
- elif stat_type_var1 == 'RB Usage (Season)':
149
- table_instance = rb_season
150
- table_instance = table_instance[table_instance['Team-Season'].isin(team_var1)]
151
- table_instance = table_instance[table_instance['Position'].isin(pos_var1)]
152
- elif stat_type_var1 == 'WR/TE Usage (Season)':
153
- table_instance = wr_season
154
- table_instance = table_instance[table_instance['Team-Season'].isin(team_var1)]
155
- table_instance = table_instance[table_instance['Position'].isin(pos_var1)]
156
-
157
- with col2:
158
- if stat_type_var1 == 'Macro Table':
159
- st.dataframe(table_instance.style.background_gradient(axis=0).background_gradient(cmap = 'RdYlGn').format(game_format, precision=2), use_container_width = True)
160
- elif stat_type_var1 == 'RB Usage (Weekly)':
161
- st.dataframe(table_instance.style.background_gradient(axis=0).background_gradient(cmap = 'RdYlGn').background_gradient(cmap='RdYlGn_r', subset = 'Utilization Rank').format(rb_util, precision=2), use_container_width = True)
162
- elif stat_type_var1 == 'WR/TE Usage (Weekly)':
163
- st.dataframe(table_instance.style.background_gradient(axis=0).background_gradient(cmap = 'RdYlGn').background_gradient(cmap='RdYlGn_r', subset = 'Utilization Rank').format(wr_te_util, precision=2), use_container_width = True)
164
- elif stat_type_var1 == 'RB Usage (Season)':
165
- st.dataframe(table_instance.style.background_gradient(axis=0).background_gradient(cmap = 'RdYlGn').background_gradient(cmap='RdYlGn_r', subset = 'Utilization Rank').format(rb_util, precision=2), use_container_width = True)
166
- elif stat_type_var1 == 'WR/TE Usage (Season)':
167
- st.dataframe(table_instance.style.background_gradient(axis=0).background_gradient(cmap = 'RdYlGn').background_gradient(cmap='RdYlGn_r', subset = 'Utilization Rank').format(wr_te_util, precision=2), use_container_width = True)
168
-
169
- st.download_button(
170
- label="Export Tables",
171
- data=convert_df_to_csv(table_instance),
172
- file_name='NFL_Research_export.csv',
173
- mime='text/csv',
174
- )
175
- with tab2:
176
- col1, col2 = st.columns([1, 8])
177
-
178
  with col1:
179
  if st.button("Load/Reset Data", key='reset2'):
180
  st.cache_data.clear()
181
  rb_search, wr_search, rb_season, wr_season, wr_matchups, macro_data, trending_data = pull_baselines()
182
- stat_type_var2 = st.radio("What table are you loading?", ('WR/TE Coverage Matchups', 'Ownership Trends', 'Nothing idk lol'))
183
  if stat_type_var2 == 'WR/TE Coverage Matchups':
184
- routes_var2 = st.slider("Is there a certain price range of routes you want to include?", 0, 50, (10, 50), key='sal_var2')
185
  split_var2 = st.radio("Are you running the the whole league or certain teams?", ('All Teams', 'Specific Teams'))
186
  pos_split2 = st.radio("Are you viewing all positions or specific positions?", ('All Positions', 'Specific Positions'))
187
  if pos_split2 == 'Specific Positions':
@@ -195,7 +139,10 @@ with tab2:
195
  team_var2 = st.multiselect('Which teams would you like to include in the Table?', options = wr_matchups['Team'].unique())
196
  elif split_var2 == 'All Teams':
197
  team_var2 = wr_matchups['Team'].unique().tolist()
198
- if stat_type_var2 == 'WR/TE Coverage Matchups':
 
 
 
199
  slate_table_instance = wr_matchups
200
  slate_table_instance = slate_table_instance[slate_table_instance['Team'].isin(team_var2)]
201
  slate_table_instance = slate_table_instance[slate_table_instance['Position'].isin(pos_var2)]
@@ -206,11 +153,13 @@ with tab2:
206
  slate_table_instance = trending_data
207
  slate_table_instance = slate_table_instance[slate_table_instance['Team'].isin(team_var2)]
208
  slate_table_instance = slate_table_instance[slate_table_instance['Position'].isin(pos_var2)]
209
- elif stat_type_var1 == 'Nothing idk lol':
210
  slate_table_instance = wr_matchups
211
 
212
  with col2:
213
- if stat_type_var2 == 'WR/TE Coverage Matchups':
 
 
214
  st.dataframe(slate_table_instance.style.background_gradient(axis=0).background_gradient(cmap = 'RdYlGn').format(wr_matchups_form, precision=2), use_container_width = True)
215
  elif stat_type_var2 == 'Ownership Trends':
216
  st.dataframe(slate_table_instance.style.background_gradient(axis=0).background_gradient(cmap = 'RdYlGn').format(trending_form, precision=2), use_container_width = True)
@@ -222,4 +171,56 @@ with tab2:
222
  data=convert_df_to_csv(slate_table_instance),
223
  file_name='NFL_Slate_Research_export.csv',
224
  mime='text/csv',
225
- )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  rb_search, wr_search, rb_season, wr_season, wr_matchups, macro_data, trending_data = pull_baselines()
116
  pos_list = ['RB', 'WR', 'TE']
117
 
118
+ tab1, tab2 = st.tabs(["Slate Specific", "Season Long Research"])
119
  with tab1:
120
  col1, col2 = st.columns([1, 8])
121
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122
  with col1:
123
  if st.button("Load/Reset Data", key='reset2'):
124
  st.cache_data.clear()
125
  rb_search, wr_search, rb_season, wr_season, wr_matchups, macro_data, trending_data = pull_baselines()
126
+ stat_type_var2 = st.radio("What table are you loading?", ('Macro Stats', 'WR/TE Coverage Matchups', 'Ownership Trends', 'Nothing idk lol'))
127
  if stat_type_var2 == 'WR/TE Coverage Matchups':
128
+ routes_var2 = st.slider("Is there a certain range of routes you want to include?", 0, 50, (10, 50), key='sal_var2')
129
  split_var2 = st.radio("Are you running the the whole league or certain teams?", ('All Teams', 'Specific Teams'))
130
  pos_split2 = st.radio("Are you viewing all positions or specific positions?", ('All Positions', 'Specific Positions'))
131
  if pos_split2 == 'Specific Positions':
 
139
  team_var2 = st.multiselect('Which teams would you like to include in the Table?', options = wr_matchups['Team'].unique())
140
  elif split_var2 == 'All Teams':
141
  team_var2 = wr_matchups['Team'].unique().tolist()
142
+ if stat_type_var2 == 'Macro Table':
143
+ slate_table_instance = macro_data
144
+ slate_table_instance = slate_table_instance.set_index('Team')
145
+ elif stat_type_var2 == 'WR/TE Coverage Matchups':
146
  slate_table_instance = wr_matchups
147
  slate_table_instance = slate_table_instance[slate_table_instance['Team'].isin(team_var2)]
148
  slate_table_instance = slate_table_instance[slate_table_instance['Position'].isin(pos_var2)]
 
153
  slate_table_instance = trending_data
154
  slate_table_instance = slate_table_instance[slate_table_instance['Team'].isin(team_var2)]
155
  slate_table_instance = slate_table_instance[slate_table_instance['Position'].isin(pos_var2)]
156
+ elif stat_type_var2 == 'Nothing idk lol':
157
  slate_table_instance = wr_matchups
158
 
159
  with col2:
160
+ if stat_type_var2 == 'Macro Table':
161
+ st.dataframe(slate_table_instance.style.background_gradient(axis=0).background_gradient(cmap = 'RdYlGn').format(game_format, precision=2), height=1000, use_container_width = True)
162
+ elif stat_type_var2 == 'WR/TE Coverage Matchups':
163
  st.dataframe(slate_table_instance.style.background_gradient(axis=0).background_gradient(cmap = 'RdYlGn').format(wr_matchups_form, precision=2), use_container_width = True)
164
  elif stat_type_var2 == 'Ownership Trends':
165
  st.dataframe(slate_table_instance.style.background_gradient(axis=0).background_gradient(cmap = 'RdYlGn').format(trending_form, precision=2), use_container_width = True)
 
171
  data=convert_df_to_csv(slate_table_instance),
172
  file_name='NFL_Slate_Research_export.csv',
173
  mime='text/csv',
174
+ )
175
+
176
+ with tab2:
177
+ col1, col2 = st.columns([1, 8])
178
+
179
+ with col1:
180
+ if st.button("Load/Reset Data", key='reset1'):
181
+ st.cache_data.clear()
182
+ rb_search, wr_search, rb_season, wr_season, wr_matchups, macro_data, trending_data = pull_baselines()
183
+ stat_type_var1 = st.radio("What table are you loading?", ('RB Usage (Weekly)', 'WR/TE Usage (Weekly)', 'RB Usage (Season)', 'WR/TE Usage (Season)'), key='stat_type_var1')
184
+ split_var1 = st.radio("Are you running the the whole league or certain teams?", ('All Teams', 'Specific Teams'), key='split_var1')
185
+ pos_split1 = st.radio("Are you viewing all positions or specific positions?", ('All Positions', 'Specific Positions'), key='pos_split1')
186
+ if pos_split1 == 'Specific Positions':
187
+ pos_var1 = st.multiselect('What Positions would you like to view?', options = ['RB', 'WR', 'TE'])
188
+ elif pos_split1 == 'All Positions':
189
+ pos_var1 = pos_list
190
+ if split_var1 == 'Specific Teams':
191
+ team_var1 = st.multiselect('Which teams would you like to include in the Table?', options = rb_search['Team-Season'].unique(), key='team_var1')
192
+ elif split_var1 == 'All Teams':
193
+ team_var1 = rb_search['Team-Season'].unique().tolist()
194
+ if stat_type_var1 == 'RB Usage (Weekly)':
195
+ table_instance = rb_search
196
+ table_instance = table_instance[table_instance['Team-Season'].isin(team_var1)]
197
+ table_instance = table_instance[table_instance['Position'].isin(pos_var1)]
198
+ elif stat_type_var1 == 'WR/TE Usage (Weekly)':
199
+ table_instance = wr_search
200
+ table_instance = table_instance[table_instance['Team-Season'].isin(team_var1)]
201
+ table_instance = table_instance[table_instance['Position'].isin(pos_var1)]
202
+ elif stat_type_var1 == 'RB Usage (Season)':
203
+ table_instance = rb_season
204
+ table_instance = table_instance[table_instance['Team-Season'].isin(team_var1)]
205
+ table_instance = table_instance[table_instance['Position'].isin(pos_var1)]
206
+ elif stat_type_var1 == 'WR/TE Usage (Season)':
207
+ table_instance = wr_season
208
+ table_instance = table_instance[table_instance['Team-Season'].isin(team_var1)]
209
+ table_instance = table_instance[table_instance['Position'].isin(pos_var1)]
210
+
211
+ with col2:
212
+ if stat_type_var1 == 'RB Usage (Weekly)':
213
+ st.dataframe(table_instance.style.background_gradient(axis=0).background_gradient(cmap = 'RdYlGn').background_gradient(cmap='RdYlGn_r', subset = 'Utilization Rank').format(rb_util, precision=2), height=1000, use_container_width = True)
214
+ elif stat_type_var1 == 'WR/TE Usage (Weekly)':
215
+ st.dataframe(table_instance.style.background_gradient(axis=0).background_gradient(cmap = 'RdYlGn').background_gradient(cmap='RdYlGn_r', subset = 'Utilization Rank').format(wr_te_util, precision=2), height=1000, use_container_width = True)
216
+ elif stat_type_var1 == 'RB Usage (Season)':
217
+ st.dataframe(table_instance.style.background_gradient(axis=0).background_gradient(cmap = 'RdYlGn').background_gradient(cmap='RdYlGn_r', subset = 'Utilization Rank').format(rb_util, precision=2), height=1000, use_container_width = True)
218
+ elif stat_type_var1 == 'WR/TE Usage (Season)':
219
+ st.dataframe(table_instance.style.background_gradient(axis=0).background_gradient(cmap = 'RdYlGn').background_gradient(cmap='RdYlGn_r', subset = 'Utilization Rank').format(wr_te_util, precision=2), height=1000, use_container_width = True)
220
+
221
+ st.download_button(
222
+ label="Export Tables",
223
+ data=convert_df_to_csv(table_instance),
224
+ file_name='NFL_Research_export.csv',
225
+ mime='text/csv',
226
+ )