Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -94,6 +94,16 @@ def wr_te_util_season():
|
|
94 |
raw_display = raw_display.sort_values(by='Utilization Rank', ascending=True)
|
95 |
return raw_display
|
96 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
97 |
@st.cache_resource(ttl = 300)
|
98 |
def macro_pull():
|
99 |
sh = gc.open_by_url(all_dk_player_projections)
|
@@ -110,63 +120,66 @@ rb_search = rb_util_weekly()
|
|
110 |
wr_search = wr_te_util_weekly()
|
111 |
rb_season = rb_util_season()
|
112 |
wr_season = wr_te_util_season()
|
|
|
113 |
macro_data = macro_pull()
|
114 |
pos_list = ['RB', 'WR', 'TE']
|
115 |
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
|
|
|
|
|
94 |
raw_display = raw_display.sort_values(by='Utilization Rank', ascending=True)
|
95 |
return raw_display
|
96 |
|
97 |
+
@st.cache_resource(ttl = 300)
|
98 |
+
def coverage_matchups():
|
99 |
+
sh = gc.open_by_url(all_dk_player_projections)
|
100 |
+
worksheet = sh.worksheet('Defensive Matchups')
|
101 |
+
raw_display = pd.DataFrame(worksheet.get_all_records())
|
102 |
+
raw_display = raw_display.replace('', np.nan)
|
103 |
+
raw_display = raw_display.sort_values(by='Utilization Rank', ascending=True)
|
104 |
+
|
105 |
+
return raw_display
|
106 |
+
|
107 |
@st.cache_resource(ttl = 300)
|
108 |
def macro_pull():
|
109 |
sh = gc.open_by_url(all_dk_player_projections)
|
|
|
120 |
wr_search = wr_te_util_weekly()
|
121 |
rb_season = rb_util_season()
|
122 |
wr_season = wr_te_util_season()
|
123 |
+
wr_matchups = coverage_matchups()
|
124 |
macro_data = macro_pull()
|
125 |
pos_list = ['RB', 'WR', 'TE']
|
126 |
|
127 |
+
tab1, tab2 = st.tabs("Season Long Research", "Slate Specific")
|
128 |
+
with tab1:
|
129 |
+
col1, col2 = st.columns([1, 8])
|
130 |
+
|
131 |
+
with col1:
|
132 |
+
if st.button("Load/Reset Data", key='reset1'):
|
133 |
+
st.cache_data.clear()
|
134 |
+
rb_search = rb_util_season()
|
135 |
+
wr_search = wr_te_util_season()
|
136 |
+
macro_data = macro_pull()
|
137 |
+
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')
|
138 |
+
split_var1 = st.radio("Are you running the the whole league or certain teams?", ('All Teams', 'Specific Teams'), key='split_var1')
|
139 |
+
pos_split1 = st.radio("Are you viewing all positions or specific positions?", ('All Positions', 'Specific Positions'), key='pos_split1')
|
140 |
+
if pos_split1 == 'Specific Positions':
|
141 |
+
pos_var1 = st.multiselect('What Positions would you like to view?', options = ['RB', 'WR', 'TE'])
|
142 |
+
elif pos_split1 == 'All Positions':
|
143 |
+
pos_var1 = pos_list
|
144 |
+
if split_var1 == 'Specific Teams':
|
145 |
+
team_var1 = st.multiselect('Which teams would you like to include in the Table?', options = rb_search['Team-Season'].unique(), key='team_var1')
|
146 |
+
elif split_var1 == 'All Teams':
|
147 |
+
team_var1 = rb_search['Team-Season'].unique().tolist()
|
148 |
+
if stat_type_var1 == 'Macro Table':
|
149 |
+
table_instance = macro_data
|
150 |
+
table_instance = table_instance.set_index('team')
|
151 |
+
elif stat_type_var1 == 'RB Usage (Weekly)':
|
152 |
+
table_instance = rb_search
|
153 |
+
table_instance = table_instance[table_instance['Team-Season'].isin(team_var1)]
|
154 |
+
table_instance = table_instance[table_instance['Position'].isin(pos_var1)]
|
155 |
+
elif stat_type_var1 == 'WR/TE Usage (Weekly)':
|
156 |
+
table_instance = wr_search
|
157 |
+
table_instance = table_instance[table_instance['Team-Season'].isin(team_var1)]
|
158 |
+
table_instance = table_instance[table_instance['Position'].isin(pos_var1)]
|
159 |
+
elif stat_type_var1 == 'RB Usage (Season)':
|
160 |
+
table_instance = rb_season
|
161 |
+
table_instance = table_instance[table_instance['Team-Season'].isin(team_var1)]
|
162 |
+
table_instance = table_instance[table_instance['Position'].isin(pos_var1)]
|
163 |
+
elif stat_type_var1 == 'WR/TE Usage (Season)':
|
164 |
+
table_instance = wr_season
|
165 |
+
table_instance = table_instance[table_instance['Team-Season'].isin(team_var1)]
|
166 |
+
table_instance = table_instance[table_instance['Position'].isin(pos_var1)]
|
167 |
+
|
168 |
+
with col2:
|
169 |
+
if stat_type_var1 == 'Macro Table':
|
170 |
+
st.dataframe(table_instance.style.background_gradient(axis=0).background_gradient(cmap = 'RdYlGn').format(game_format, precision=2), use_container_width = True)
|
171 |
+
elif stat_type_var1 == 'RB Usage (Weekly)':
|
172 |
+
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)
|
173 |
+
elif stat_type_var1 == 'WR/TE Usage (Weekly)':
|
174 |
+
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)
|
175 |
+
elif stat_type_var1 == 'RB Usage (Season)':
|
176 |
+
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)
|
177 |
+
elif stat_type_var1 == 'WR/TE Usage (Season)':
|
178 |
+
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)
|
179 |
+
|
180 |
+
st.download_button(
|
181 |
+
label="Export Tables",
|
182 |
+
data=convert_df_to_csv(table_instance),
|
183 |
+
file_name='NFL_Research_export.csv',
|
184 |
+
mime='text/csv',
|
185 |
+
)
|