James McCool commited on
Commit
3feca2c
·
1 Parent(s): 1194fb6

Added loop for top 10 owned players

Browse files
Files changed (1) hide show
  1. app.py +184 -87
app.py CHANGED
@@ -78,12 +78,12 @@ def player_stat_table():
78
  worksheet = sh.worksheet('DK_ROO')
79
  load_display = pd.DataFrame(worksheet.get_all_records())
80
  load_display.replace('', np.nan, inplace=True)
81
- dk_roo_raw = load_display.dropna(subset=['Median'])
82
 
83
  worksheet = sh.worksheet('FD_ROO')
84
  load_display = pd.DataFrame(worksheet.get_all_records())
85
  load_display.replace('', np.nan, inplace=True)
86
- fd_roo_raw = load_display.dropna(subset=['Median'])
87
 
88
  worksheet = sh.worksheet('Site_Info')
89
  site_slates = pd.DataFrame(worksheet.get_all_records())
@@ -123,7 +123,11 @@ with tab1:
123
  elif data_var1 != 'User':
124
  raw_baselines = fd_roo_raw[fd_roo_raw['slate'] == 'Main Slate']
125
  raw_baselines = raw_baselines[raw_baselines['version'] == 'overall']
126
- player_check = st.selectbox('Select player to create comps', options = dk_roo_raw['Player'].unique(), key='dk_player')
 
 
 
 
127
  Salary_var = st.number_input('Acceptable +/- Salary range', min_value = 0, max_value = 1000, value = 300, step = 100)
128
  Median_var = st.number_input('Acceptable +/- Median range', min_value = 0, max_value = 10, value = 3, step = 1)
129
  pos_var1 = st.radio("Compare to all positions or specific positions?", ('All Positions', 'Specific Positions'), key='pos_var1')
@@ -153,90 +157,183 @@ with tab1:
153
  team_dict = dict(zip(working_roo.Player, working_roo.Team))
154
  opp_dict = dict(zip(working_roo.Player, working_roo.Opp))
155
  total_sims = 1000
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
156
 
157
- player_var = working_roo.loc[working_roo['Player'] == player_check]
158
- player_var = player_var.reset_index()
159
-
160
- working_roo = working_roo[working_roo['Position'].isin(pos_var_list)]
161
- working_roo = working_roo[working_roo['Team'].isin(team_var1)]
162
- working_roo = working_roo.loc[(working_roo['Salary'] >= player_var['Salary'][0] - Salary_var) & (working_roo['Salary'] <= player_var['Salary'][0] + Salary_var)]
163
- working_roo = working_roo.loc[(working_roo['Median'] >= player_var['Median'][0] - Median_var) & (working_roo['Median'] <= player_var['Median'][0] + Median_var)]
164
-
165
- flex_file = working_roo[['Player', 'Position', 'Salary', 'Median']]
166
- flex_file['Floor_raw'] = flex_file['Median'] * .20
167
- flex_file['Ceiling_raw'] = flex_file['Median'] * 1.9
168
- flex_file['Floor'] = np.where(flex_file['Position'] == 'QB', (flex_file['Median'] * .33), flex_file['Floor_raw'])
169
- flex_file['Floor'] = np.where(flex_file['Position'] == 'RB', (flex_file['Median'] * .15), flex_file['Floor_raw'])
170
- flex_file['Ceiling'] = np.where(flex_file['Position'] == 'QB', (flex_file['Median'] * 1.75), flex_file['Ceiling_raw'])
171
- flex_file['Ceiling'] = np.where(flex_file['Position'] == 'RB', (flex_file['Median'] * 1.85), flex_file['Ceiling_raw'])
172
- flex_file['STD'] = flex_file['Median'] / 4
173
- flex_file = flex_file[['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD']]
174
- hold_file = flex_file
175
- overall_file = flex_file
176
- salary_file = flex_file
177
-
178
- overall_players = overall_file[['Player']]
179
-
180
- for x in range(0,total_sims):
181
- salary_file[x] = salary_file['Salary']
182
-
183
- salary_file=salary_file.drop(['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
184
- salary_file.astype('int').dtypes
185
-
186
- salary_file = salary_file.div(1000)
187
-
188
- for x in range(0,total_sims):
189
- overall_file[x] = np.random.normal(overall_file['Median'],overall_file['STD'])
190
-
191
- overall_file=overall_file.drop(['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
192
- overall_file.astype('int').dtypes
193
-
194
- players_only = hold_file[['Player']]
195
- raw_lineups_file = players_only
196
-
197
- for x in range(0,total_sims):
198
- maps_dict = {'proj_map':dict(zip(hold_file.Player,hold_file[x]))}
199
- raw_lineups_file[x] = sum([raw_lineups_file['Player'].map(maps_dict['proj_map'])])
200
- players_only[x] = raw_lineups_file[x].rank(ascending=False)
201
-
202
- players_only=players_only.drop(['Player'], axis=1)
203
- players_only.astype('int').dtypes
204
-
205
- salary_2x_check = (overall_file - (salary_file*2))
206
- salary_3x_check = (overall_file - (salary_file*3))
207
- salary_4x_check = (overall_file - (salary_file*4))
208
-
209
- players_only['Average_Rank'] = players_only.mean(axis=1)
210
- players_only['Top_finish'] = players_only[players_only == 1].count(axis=1)/total_sims
211
- players_only['Top_5_finish'] = players_only[players_only <= 5].count(axis=1)/total_sims
212
- players_only['Top_10_finish'] = players_only[players_only <= 10].count(axis=1)/total_sims
213
- players_only['20+%'] = overall_file[overall_file >= 20].count(axis=1)/float(total_sims)
214
- players_only['2x%'] = salary_2x_check[salary_2x_check >= 1].count(axis=1)/float(total_sims)
215
- players_only['3x%'] = salary_3x_check[salary_3x_check >= 1].count(axis=1)/float(total_sims)
216
- players_only['4x%'] = salary_4x_check[salary_4x_check >= 1].count(axis=1)/float(total_sims)
217
-
218
- players_only['Player'] = hold_file[['Player']]
219
-
220
- final_outcomes = players_only[['Player', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%']]
221
-
222
- final_Proj = pd.merge(hold_file, final_outcomes, on="Player")
223
- final_Proj = final_Proj[['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%']]
224
- final_Proj['Own'] = final_Proj['Player'].map(own_dict)
225
- final_Proj['Team'] = final_Proj['Player'].map(team_dict)
226
- final_Proj['Opp'] = final_Proj['Player'].map(opp_dict)
227
- final_Proj = final_Proj[['Player', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%', 'Own']]
228
- final_Proj['Projection Rank'] = final_Proj.Median.rank(pct = True)
229
- final_Proj['Own Rank'] = final_Proj.Own.rank(pct = True)
230
- final_Proj['LevX'] = 0
231
- final_Proj['LevX'] = np.where(final_Proj['Position'] == 'QB', final_Proj[['Projection Rank', 'Top_5_finish']].mean(axis=1) + final_Proj['4x%'] - final_Proj['Own Rank'], final_Proj['LevX'])
232
- final_Proj['LevX'] = np.where(final_Proj['Position'] == 'TE', final_Proj[['Projection Rank', '2x%']].mean(axis=1) + final_Proj['4x%'] - final_Proj['Own Rank'], final_Proj['LevX'])
233
- final_Proj['LevX'] = np.where(final_Proj['Position'] == 'RB', final_Proj[['Projection Rank', 'Top_5_finish']].mean(axis=1) + final_Proj['20+%'] - final_Proj['Own Rank'], final_Proj['LevX'])
234
- final_Proj['LevX'] = np.where(final_Proj['Position'] == 'WR', final_Proj[['Projection Rank', 'Top_10_finish']].mean(axis=1) + final_Proj['4x%'] - final_Proj['Own Rank'], final_Proj['LevX'])
235
- final_Proj['CPT_Own'] = final_Proj['Own'] / 4
236
-
237
- final_Proj = final_Proj[['Player', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%', 'Own', 'LevX']]
238
- final_Proj = final_Proj.set_index('Player')
239
- final_Proj = final_Proj.sort_values(by='Top_finish', ascending=False)
240
 
241
  with hold_container:
242
  hold_container = st.empty()
@@ -249,7 +346,7 @@ with tab1:
249
  file_name='NFL_pivot_export.csv',
250
  mime='text/csv',
251
  )
252
-
253
  with tab2:
254
  st.info("The Projections file can have any columns in any order, but must contain columns explicitly named: 'Player', 'Salary', 'Position', 'Team', 'Opp', 'Median', and 'Own'.")
255
  col1, col2 = st.columns([1, 5])
 
78
  worksheet = sh.worksheet('DK_ROO')
79
  load_display = pd.DataFrame(worksheet.get_all_records())
80
  load_display.replace('', np.nan, inplace=True)
81
+ dk_roo_raw = load_display.dropna(subset=['Own'])
82
 
83
  worksheet = sh.worksheet('FD_ROO')
84
  load_display = pd.DataFrame(worksheet.get_all_records())
85
  load_display.replace('', np.nan, inplace=True)
86
+ fd_roo_raw = load_display.dropna(subset=['Own'])
87
 
88
  worksheet = sh.worksheet('Site_Info')
89
  site_slates = pd.DataFrame(worksheet.get_all_records())
 
123
  elif data_var1 != 'User':
124
  raw_baselines = fd_roo_raw[fd_roo_raw['slate'] == 'Main Slate']
125
  raw_baselines = raw_baselines[raw_baselines['version'] == 'overall']
126
+ check_seq = st.radio("Do you want to check a single player or the top 10 in ownership?", ('Single Player', 'Top 10 Owned'), key='check_seq')
127
+ if check_seq == 'Single Player':
128
+ player_check = st.selectbox('Select player to create comps', options = raw_baselines['Player'].unique(), key='dk_player')
129
+ elif check_seq == 'Top 10 Owned':
130
+ player_check = raw_baselines['Player'].head(10).tolist()
131
  Salary_var = st.number_input('Acceptable +/- Salary range', min_value = 0, max_value = 1000, value = 300, step = 100)
132
  Median_var = st.number_input('Acceptable +/- Median range', min_value = 0, max_value = 10, value = 3, step = 1)
133
  pos_var1 = st.radio("Compare to all positions or specific positions?", ('All Positions', 'Specific Positions'), key='pos_var1')
 
157
  team_dict = dict(zip(working_roo.Player, working_roo.Team))
158
  opp_dict = dict(zip(working_roo.Player, working_roo.Opp))
159
  total_sims = 1000
160
+ if check_seq == 'Single Player':
161
+ player_var = working_roo.loc[working_roo['Player'] == player_check]
162
+ player_var = player_var.reset_index()
163
+
164
+ working_roo = working_roo[working_roo['Position'].isin(pos_var_list)]
165
+ working_roo = working_roo[working_roo['Team'].isin(team_var1)]
166
+ working_roo = working_roo.loc[(working_roo['Salary'] >= player_var['Salary'][0] - Salary_var) & (working_roo['Salary'] <= player_var['Salary'][0] + Salary_var)]
167
+ working_roo = working_roo.loc[(working_roo['Median'] >= player_var['Median'][0] - Median_var) & (working_roo['Median'] <= player_var['Median'][0] + Median_var)]
168
+
169
+ flex_file = working_roo[['Player', 'Position', 'Salary', 'Median']]
170
+ flex_file['Floor_raw'] = flex_file['Median'] * .25
171
+ flex_file['Ceiling_raw'] = flex_file['Median'] * 1.75
172
+ flex_file['Floor'] = np.where(flex_file['Position'] == 'QB', (flex_file['Median'] * .33), flex_file['Floor_raw'])
173
+ flex_file['Floor'] = np.where(flex_file['Position'] == 'WR', (flex_file['Median'] * .15), flex_file['Floor_raw'])
174
+ flex_file['Ceiling'] = np.where(flex_file['Position'] == 'QB', (flex_file['Median'] * 1.75), flex_file['Ceiling_raw'])
175
+ flex_file['Ceiling'] = np.where(flex_file['Position'] == 'WR', (flex_file['Median'] * 1.85), flex_file['Ceiling_raw'])
176
+ flex_file['STD'] = flex_file['Median'] / 4
177
+ flex_file = flex_file[['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD']]
178
+ hold_file = flex_file.copy()
179
+ overall_file = flex_file.copy()
180
+ salary_file = flex_file.copy()
181
+
182
+ overall_players = overall_file[['Player']]
183
+
184
+ for x in range(0,total_sims):
185
+ salary_file[x] = salary_file['Salary']
186
+
187
+ salary_file=salary_file.drop(['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
188
+ salary_file.astype('int').dtypes
189
+
190
+ salary_file = salary_file.div(1000)
191
+
192
+ for x in range(0,total_sims):
193
+ overall_file[x] = np.random.normal(overall_file['Median'],overall_file['STD'])
194
+
195
+ overall_file=overall_file.drop(['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
196
+ overall_file.astype('int').dtypes
197
+
198
+ players_only = hold_file[['Player']]
199
+ raw_lineups_file = players_only
200
+
201
+ for x in range(0,total_sims):
202
+ maps_dict = {'proj_map':dict(zip(hold_file.Player,hold_file[x]))}
203
+ raw_lineups_file[x] = sum([raw_lineups_file['Player'].map(maps_dict['proj_map'])])
204
+ players_only[x] = raw_lineups_file[x].rank(ascending=False)
205
+
206
+ players_only=players_only.drop(['Player'], axis=1)
207
+ players_only.astype('int').dtypes
208
+
209
+ salary_2x_check = (overall_file - (salary_file*2))
210
+ salary_3x_check = (overall_file - (salary_file*3))
211
+ salary_4x_check = (overall_file - (salary_file*4))
212
+
213
+ players_only['Average_Rank'] = players_only.mean(axis=1)
214
+ players_only['Top_finish'] = players_only[players_only == 1].count(axis=1)/total_sims
215
+ players_only['Top_5_finish'] = players_only[players_only <= 5].count(axis=1)/total_sims
216
+ players_only['Top_10_finish'] = players_only[players_only <= 10].count(axis=1)/total_sims
217
+ players_only['20+%'] = overall_file[overall_file >= 20].count(axis=1)/float(total_sims)
218
+ players_only['2x%'] = salary_2x_check[salary_2x_check >= 1].count(axis=1)/float(total_sims)
219
+ players_only['3x%'] = salary_3x_check[salary_3x_check >= 1].count(axis=1)/float(total_sims)
220
+ players_only['4x%'] = salary_4x_check[salary_4x_check >= 1].count(axis=1)/float(total_sims)
221
+
222
+ players_only['Player'] = hold_file[['Player']]
223
+
224
+ final_outcomes = players_only[['Player', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%']]
225
+
226
+ final_Proj = pd.merge(hold_file, final_outcomes, on="Player")
227
+ final_Proj = final_Proj[['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%']]
228
+ final_Proj['Own'] = final_Proj['Player'].map(own_dict)
229
+ final_Proj['Team'] = final_Proj['Player'].map(team_dict)
230
+ final_Proj['Opp'] = final_Proj['Player'].map(opp_dict)
231
+ final_Proj = final_Proj[['Player', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%', 'Own']]
232
+ final_Proj['Projection Rank'] = final_Proj.Median.rank(pct = True)
233
+ final_Proj['Own Rank'] = final_Proj.Own.rank(pct = True)
234
+ final_Proj['LevX'] = 0
235
+ final_Proj['LevX'] = np.where(final_Proj['Position'] == 'QB', final_Proj[['Projection Rank', 'Top_5_finish']].mean(axis=1) + final_Proj['4x%'] - final_Proj['Own Rank'], final_Proj['LevX'])
236
+ final_Proj['LevX'] = np.where(final_Proj['Position'] == 'TE', final_Proj[['Projection Rank', '2x%']].mean(axis=1) + final_Proj['4x%'] - final_Proj['Own Rank'], final_Proj['LevX'])
237
+ final_Proj['LevX'] = np.where(final_Proj['Position'] == 'RB', final_Proj[['Projection Rank', 'Top_5_finish']].mean(axis=1) + final_Proj['20+%'] - final_Proj['Own Rank'], final_Proj['LevX'])
238
+ final_Proj['LevX'] = np.where(final_Proj['Position'] == 'WR', final_Proj[['Projection Rank', 'Top_10_finish']].mean(axis=1) + final_Proj['4x%'] - final_Proj['Own Rank'], final_Proj['LevX'])
239
+ final_Proj['CPT_Own'] = final_Proj['Own'] / 4
240
+
241
+ final_Proj = final_Proj[['Player', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%', 'Own', 'LevX']]
242
+ final_Proj = final_Proj.set_index('Player')
243
+ final_Proj = final_Proj.sort_values(by='Top_finish', ascending=False)
244
+ elif check_seq == 'Top 10 Owned':
245
+ final_proj_list = []
246
+ for players in player_check:
247
+ player_var = working_roo.loc[working_roo['Player'] == players]
248
+ player_var = player_var.reset_index()
249
+
250
+ working_roo_temp = working_roo[working_roo['Position'].isin(pos_var_list)]
251
+ working_roo_temp = working_roo_temp[working_roo_temp['Team'].isin(team_var1)]
252
+ working_roo_temp = working_roo_temp.loc[(working_roo_temp['Salary'] >= player_var['Salary'][0] - Salary_var) & (working_roo_temp['Salary'] <= player_var['Salary'][0] + Salary_var)]
253
+ working_roo_temp = working_roo_temp.loc[(working_roo_temp['Median'] >= player_var['Median'][0] - Median_var) & (working_roo_temp['Median'] <= player_var['Median'][0] + Median_var)]
254
+
255
+ flex_file = working_roo_temp[['Player', 'Position', 'Salary', 'Median']]
256
+ flex_file['Floor_raw'] = flex_file['Median'] * .25
257
+ flex_file['Ceiling_raw'] = flex_file['Median'] * 1.75
258
+ flex_file['Floor'] = np.where(flex_file['Position'] == 'QB', (flex_file['Median'] * .33), flex_file['Floor_raw'])
259
+ flex_file['Floor'] = np.where(flex_file['Position'] == 'WR', (flex_file['Median'] * .15), flex_file['Floor_raw'])
260
+ flex_file['Ceiling'] = np.where(flex_file['Position'] == 'QB', (flex_file['Median'] * 1.75), flex_file['Ceiling_raw'])
261
+ flex_file['Ceiling'] = np.where(flex_file['Position'] == 'WR', (flex_file['Median'] * 1.85), flex_file['Ceiling_raw'])
262
+ flex_file['STD'] = flex_file['Median'] / 4
263
+ flex_file = flex_file[['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD']]
264
+ hold_file = flex_file.copy()
265
+ overall_file = flex_file.copy()
266
+ salary_file = flex_file.copy()
267
+
268
+ overall_players = overall_file[['Player']]
269
+
270
+ for x in range(0,total_sims):
271
+ salary_file[x] = salary_file['Salary']
272
+
273
+ salary_file=salary_file.drop(['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
274
+ salary_file.astype('int').dtypes
275
+
276
+ salary_file = salary_file.div(1000)
277
+
278
+ for x in range(0,total_sims):
279
+ overall_file[x] = np.random.normal(overall_file['Median'],overall_file['STD'])
280
+
281
+ overall_file=overall_file.drop(['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'STD'], axis=1)
282
+ overall_file.astype('int').dtypes
283
+
284
+ players_only = hold_file[['Player']]
285
+ raw_lineups_file = players_only
286
+
287
+ for x in range(0,total_sims):
288
+ maps_dict = {'proj_map':dict(zip(hold_file.Player,hold_file[x]))}
289
+ raw_lineups_file[x] = sum([raw_lineups_file['Player'].map(maps_dict['proj_map'])])
290
+ players_only[x] = raw_lineups_file[x].rank(ascending=False)
291
+
292
+ players_only=players_only.drop(['Player'], axis=1)
293
+ players_only.astype('int').dtypes
294
+
295
+ salary_2x_check = (overall_file - (salary_file*2))
296
+ salary_3x_check = (overall_file - (salary_file*3))
297
+ salary_4x_check = (overall_file - (salary_file*4))
298
+
299
+ players_only['Average_Rank'] = players_only.mean(axis=1)
300
+ players_only['Top_finish'] = players_only[players_only == 1].count(axis=1)/total_sims
301
+ players_only['Top_5_finish'] = players_only[players_only <= 5].count(axis=1)/total_sims
302
+ players_only['Top_10_finish'] = players_only[players_only <= 10].count(axis=1)/total_sims
303
+ players_only['20+%'] = overall_file[overall_file >= 20].count(axis=1)/float(total_sims)
304
+ players_only['2x%'] = salary_2x_check[salary_2x_check >= 1].count(axis=1)/float(total_sims)
305
+ players_only['3x%'] = salary_3x_check[salary_3x_check >= 1].count(axis=1)/float(total_sims)
306
+ players_only['4x%'] = salary_4x_check[salary_4x_check >= 1].count(axis=1)/float(total_sims)
307
+
308
+ players_only['Player'] = hold_file[['Player']]
309
+
310
+ final_outcomes = players_only[['Player', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%']]
311
+
312
+ final_Proj = pd.merge(hold_file, final_outcomes, on="Player")
313
+ final_Proj = final_Proj[['Player', 'Position', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%']]
314
+ final_Proj['Own'] = final_Proj['Player'].map(own_dict)
315
+ final_Proj['Team'] = final_Proj['Player'].map(team_dict)
316
+ final_Proj['Opp'] = final_Proj['Player'].map(opp_dict)
317
+ final_Proj = final_Proj[['Player', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%', 'Own']]
318
+ final_Proj['Projection Rank'] = final_Proj.Median.rank(pct = True)
319
+ final_Proj['Own Rank'] = final_Proj.Own.rank(pct = True)
320
+ final_Proj['LevX'] = 0
321
+ final_Proj['LevX'] = np.where(final_Proj['Position'] == 'QB', final_Proj[['Projection Rank', 'Top_5_finish']].mean(axis=1) + final_Proj['4x%'] - final_Proj['Own Rank'], final_Proj['LevX'])
322
+ final_Proj['LevX'] = np.where(final_Proj['Position'] == 'TE', final_Proj[['Projection Rank', '2x%']].mean(axis=1) + final_Proj['4x%'] - final_Proj['Own Rank'], final_Proj['LevX'])
323
+ final_Proj['LevX'] = np.where(final_Proj['Position'] == 'RB', final_Proj[['Projection Rank', 'Top_5_finish']].mean(axis=1) + final_Proj['20+%'] - final_Proj['Own Rank'], final_Proj['LevX'])
324
+ final_Proj['LevX'] = np.where(final_Proj['Position'] == 'WR', final_Proj[['Projection Rank', 'Top_10_finish']].mean(axis=1) + final_Proj['4x%'] - final_Proj['Own Rank'], final_Proj['LevX'])
325
+ final_Proj['CPT_Own'] = final_Proj['Own'] / 4
326
+
327
+ final_Proj = final_Proj[['Player', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%', 'Own', 'LevX']]
328
+
329
+ final_Proj = final_Proj.set_index('Player')
330
+ final_Proj = final_Proj.sort_values(by='Top_finish', ascending=False)
331
+ final_proj_list.append(final_Proj)
332
 
333
+ # Concatenate all the final_Proj dataframes
334
+ final_Proj_combined = pd.concat(final_proj_list)
335
+ final_Proj_combined = final_Proj_combined.sort_values(by='Top_finish', ascending=False)
336
+ final_Proj = final_Proj_combined # Assign the combined dataframe back to final_Proj
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
337
 
338
  with hold_container:
339
  hold_container = st.empty()
 
346
  file_name='NFL_pivot_export.csv',
347
  mime='text/csv',
348
  )
349
+
350
  with tab2:
351
  st.info("The Projections file can have any columns in any order, but must contain columns explicitly named: 'Player', 'Salary', 'Position', 'Team', 'Opp', 'Median', and 'Own'.")
352
  col1, col2 = st.columns([1, 5])