Spaces:
Running
Running
James McCool
commited on
Commit
·
ef3585b
1
Parent(s):
3feca2c
Cleaned up loop for top 10 owned ported from NHL version
Browse files
app.py
CHANGED
@@ -142,9 +142,12 @@ with tab1:
|
|
142 |
team_var1 = raw_baselines.Team.values.tolist()
|
143 |
|
144 |
with col2:
|
145 |
-
|
|
|
|
|
|
|
146 |
if st.button('Simulate appropriate pivots'):
|
147 |
-
with
|
148 |
if site_var1 == 'Draftkings':
|
149 |
working_roo = raw_baselines
|
150 |
working_roo.replace('', 0, inplace=True)
|
@@ -156,7 +159,9 @@ with tab1:
|
|
156 |
own_dict = dict(zip(working_roo.Player, working_roo.Own))
|
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()
|
@@ -199,7 +204,7 @@ with tab1:
|
|
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,
|
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 |
|
@@ -240,10 +245,12 @@ with tab1:
|
|
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 |
|
@@ -285,7 +292,7 @@ with tab1:
|
|
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,
|
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 |
|
@@ -326,26 +333,30 @@ with tab1:
|
|
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 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
final_Proj = final_Proj
|
341 |
-
st.dataframe(final_Proj.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(player_roo_format, precision=2), use_container_width = True)
|
342 |
|
343 |
-
|
|
|
|
|
|
|
|
|
344 |
label="Export Tables",
|
345 |
-
data=convert_df_to_csv(final_Proj),
|
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'.")
|
|
|
142 |
team_var1 = raw_baselines.Team.values.tolist()
|
143 |
|
144 |
with col2:
|
145 |
+
placeholder = st.empty()
|
146 |
+
displayholder = st.empty()
|
147 |
+
|
148 |
+
|
149 |
if st.button('Simulate appropriate pivots'):
|
150 |
+
with placeholder:
|
151 |
if site_var1 == 'Draftkings':
|
152 |
working_roo = raw_baselines
|
153 |
working_roo.replace('', 0, inplace=True)
|
|
|
159 |
own_dict = dict(zip(working_roo.Player, working_roo.Own))
|
160 |
team_dict = dict(zip(working_roo.Player, working_roo.Team))
|
161 |
opp_dict = dict(zip(working_roo.Player, working_roo.Opp))
|
162 |
+
pos_dict = dict(zip(working_roo.Player, working_roo.Position))
|
163 |
total_sims = 1000
|
164 |
+
|
165 |
if check_seq == 'Single Player':
|
166 |
player_var = working_roo.loc[working_roo['Player'] == player_check]
|
167 |
player_var = player_var.reset_index()
|
|
|
204 |
raw_lineups_file = players_only
|
205 |
|
206 |
for x in range(0,total_sims):
|
207 |
+
maps_dict = {'proj_map':dict(zip(hold_file.Player,overall_file[x]))}
|
208 |
raw_lineups_file[x] = sum([raw_lineups_file['Player'].map(maps_dict['proj_map'])])
|
209 |
players_only[x] = raw_lineups_file[x].rank(ascending=False)
|
210 |
|
|
|
245 |
|
246 |
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']]
|
247 |
final_Proj = final_Proj.set_index('Player')
|
248 |
+
st.session_state.final_Proj = final_Proj.sort_values(by='Top_finish', ascending=False)
|
249 |
+
|
250 |
elif check_seq == 'Top 10 Owned':
|
251 |
final_proj_list = []
|
252 |
for players in player_check:
|
253 |
+
players_pos = pos_dict[players]
|
254 |
player_var = working_roo.loc[working_roo['Player'] == players]
|
255 |
player_var = player_var.reset_index()
|
256 |
|
|
|
292 |
raw_lineups_file = players_only
|
293 |
|
294 |
for x in range(0,total_sims):
|
295 |
+
maps_dict = {'proj_map':dict(zip(hold_file.Player,overall_file[x]))}
|
296 |
raw_lineups_file[x] = sum([raw_lineups_file['Player'].map(maps_dict['proj_map'])])
|
297 |
players_only[x] = raw_lineups_file[x].rank(ascending=False)
|
298 |
|
|
|
333 |
|
334 |
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']]
|
335 |
|
|
|
336 |
final_Proj = final_Proj.sort_values(by='Top_finish', ascending=False)
|
337 |
final_proj_list.append(final_Proj)
|
338 |
+
st.write(f'finished run for {players}')
|
339 |
|
340 |
+
# Concatenate all the final_Proj dataframes
|
341 |
+
final_Proj_combined = pd.concat(final_proj_list)
|
342 |
+
final_Proj_combined = final_Proj_combined.sort_values(by='LevX', ascending=False)
|
343 |
+
final_Proj_combined = final_Proj_combined[final_Proj_combined['Player'] != final_Proj_combined['Pivot_source']]
|
344 |
+
st.session_state.final_Proj = final_Proj_combined.reset_index(drop=True) # Assign the combined dataframe back to final_Proj
|
345 |
+
|
346 |
+
placeholder.empty()
|
|
|
|
|
347 |
|
348 |
+
with displayholder.container():
|
349 |
+
if 'final_Proj' in st.session_state:
|
350 |
+
st.dataframe(st.session_state.final_Proj.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(player_roo_format, precision=2), use_container_width = True)
|
351 |
+
|
352 |
+
st.download_button(
|
353 |
label="Export Tables",
|
354 |
+
data=convert_df_to_csv(st.session_state.final_Proj),
|
355 |
file_name='NFL_pivot_export.csv',
|
356 |
mime='text/csv',
|
357 |
+
)
|
358 |
+
else:
|
359 |
+
st.write("Run some pivots my dude/dudette")
|
360 |
|
361 |
with tab2:
|
362 |
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'.")
|