Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -366,7 +366,7 @@ with tab1:
|
|
366 |
columns=['Player','Freq']).sort_values('Freq', ascending=False).reset_index(drop=True)
|
367 |
freq_working['Freq'] = freq_working['Freq'].astype(int)
|
368 |
freq_working['Position'] = freq_working['Player'].map(maps_dict['Pos_map'])
|
369 |
-
freq_working['Salary'] = freq_working['Player'].map(maps_dict['Salary_map'])
|
370 |
freq_working['Proj Own'] = freq_working['Player'].map(maps_dict['Own_map']) / 100
|
371 |
freq_working['Exposure'] = freq_working['Freq']/(1000)
|
372 |
freq_working['Edge'] = freq_working['Exposure'] - freq_working['Proj Own']
|
@@ -382,11 +382,26 @@ with tab1:
|
|
382 |
cpt_working['Freq'] = cpt_working['Freq'].astype(int)
|
383 |
cpt_working['Position'] = cpt_working['Player'].map(maps_dict['Pos_map'])
|
384 |
cpt_working['Salary'] = cpt_working['Player'].map(maps_dict['Salary_map'])
|
385 |
-
cpt_working['Proj Own'] = cpt_working['Player'].map(maps_dict['Own_map']) /
|
386 |
cpt_working['Exposure'] = cpt_working['Freq']/(1000)
|
387 |
cpt_working['Edge'] = cpt_working['Exposure'] - cpt_working['Proj Own']
|
388 |
cpt_working['Team'] = cpt_working['Player'].map(maps_dict['Team_map'])
|
389 |
st.session_state.sp_freq = cpt_working.copy()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
390 |
|
391 |
if sim_site_var1 == 'Draftkings':
|
392 |
team_working = pd.DataFrame(np.column_stack(np.unique(freq_copy.iloc[:,8:9].values, return_counts=True)),
|
@@ -434,7 +449,7 @@ with tab1:
|
|
434 |
)
|
435 |
|
436 |
with st.container():
|
437 |
-
tab1, tab2, tab3, tab4 = st.tabs(['Overall Exposures', 'CPT Exposures', '
|
438 |
with tab1:
|
439 |
if 'player_freq' in st.session_state:
|
440 |
|
@@ -458,24 +473,24 @@ with tab1:
|
|
458 |
key='sp'
|
459 |
)
|
460 |
with tab3:
|
461 |
-
if '
|
462 |
|
463 |
st.dataframe(st.session_state.team_freq.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(percentages_format, precision=2), use_container_width = True)
|
464 |
st.download_button(
|
465 |
label="Export Exposures",
|
466 |
-
data=st.session_state.
|
467 |
-
file_name='
|
468 |
mime='text/csv',
|
469 |
-
key='
|
470 |
)
|
471 |
with tab4:
|
472 |
-
if '
|
473 |
|
474 |
-
st.dataframe(st.session_state.
|
475 |
st.download_button(
|
476 |
label="Export Exposures",
|
477 |
-
data=st.session_state.
|
478 |
-
file_name='
|
479 |
mime='text/csv',
|
480 |
-
key='
|
481 |
)
|
|
|
366 |
columns=['Player','Freq']).sort_values('Freq', ascending=False).reset_index(drop=True)
|
367 |
freq_working['Freq'] = freq_working['Freq'].astype(int)
|
368 |
freq_working['Position'] = freq_working['Player'].map(maps_dict['Pos_map'])
|
369 |
+
freq_working['Salary'] = freq_working['Player'].map(maps_dict['Salary_map']) / 1.5
|
370 |
freq_working['Proj Own'] = freq_working['Player'].map(maps_dict['Own_map']) / 100
|
371 |
freq_working['Exposure'] = freq_working['Freq']/(1000)
|
372 |
freq_working['Edge'] = freq_working['Exposure'] - freq_working['Proj Own']
|
|
|
382 |
cpt_working['Freq'] = cpt_working['Freq'].astype(int)
|
383 |
cpt_working['Position'] = cpt_working['Player'].map(maps_dict['Pos_map'])
|
384 |
cpt_working['Salary'] = cpt_working['Player'].map(maps_dict['Salary_map'])
|
385 |
+
cpt_working['Proj Own'] = cpt_working['Player'].map(maps_dict['Own_map']) / 400
|
386 |
cpt_working['Exposure'] = cpt_working['Freq']/(1000)
|
387 |
cpt_working['Edge'] = cpt_working['Exposure'] - cpt_working['Proj Own']
|
388 |
cpt_working['Team'] = cpt_working['Player'].map(maps_dict['Team_map'])
|
389 |
st.session_state.sp_freq = cpt_working.copy()
|
390 |
+
|
391 |
+
if sim_site_var1 == 'Draftkings':
|
392 |
+
flex_working = pd.DataFrame(np.column_stack(np.unique(freq_copy.iloc[:,1:6].values, return_counts=True)),
|
393 |
+
columns=['Player','Freq']).sort_values('Freq', ascending=False).reset_index(drop=True)
|
394 |
+
elif sim_site_var1 == 'Fanduel':
|
395 |
+
flex_working = pd.DataFrame(np.column_stack(np.unique(freq_copy.iloc[:,1:5].values, return_counts=True)),
|
396 |
+
columns=['Player','Freq']).sort_values('Freq', ascending=False).reset_index(drop=True)
|
397 |
+
flex_working['Freq'] = flex_working['Freq'].astype(int)
|
398 |
+
flex_working['Position'] = flex_working['Player'].map(maps_dict['Pos_map'])
|
399 |
+
flex_working['Salary'] = flex_working['Player'].map(maps_dict['Salary_map'])
|
400 |
+
flex_working['Proj Own'] = (flex_working['Player'].map(maps_dict['Own_map']) / 100) - (flex_working['Player'].map(maps_dict['Own_map']) / 400)
|
401 |
+
flex_working['Exposure'] = flex_working['Freq']/(1000)
|
402 |
+
flex_working['Edge'] = flex_working['Exposure'] - flex_working['Proj Own']
|
403 |
+
flex_working['Team'] = flex_working['Player'].map(maps_dict['Team_map'])
|
404 |
+
st.session_state.flex_freq = flex_working.copy()
|
405 |
|
406 |
if sim_site_var1 == 'Draftkings':
|
407 |
team_working = pd.DataFrame(np.column_stack(np.unique(freq_copy.iloc[:,8:9].values, return_counts=True)),
|
|
|
449 |
)
|
450 |
|
451 |
with st.container():
|
452 |
+
tab1, tab2, tab3, tab4 = st.tabs(['Overall Exposures', 'CPT Exposures', 'FLEX Exposures', 'Team Exposures'])
|
453 |
with tab1:
|
454 |
if 'player_freq' in st.session_state:
|
455 |
|
|
|
473 |
key='sp'
|
474 |
)
|
475 |
with tab3:
|
476 |
+
if 'flex_freq' in st.session_state:
|
477 |
|
478 |
st.dataframe(st.session_state.team_freq.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(percentages_format, precision=2), use_container_width = True)
|
479 |
st.download_button(
|
480 |
label="Export Exposures",
|
481 |
+
data=st.session_state.flex_freq.to_csv().encode('utf-8'),
|
482 |
+
file_name='flex_freq.csv',
|
483 |
mime='text/csv',
|
484 |
+
key='flex'
|
485 |
)
|
486 |
with tab4:
|
487 |
+
if 'team_freq' in st.session_state:
|
488 |
|
489 |
+
st.dataframe(st.session_state.team_freq.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(percentages_format, precision=2), use_container_width = True)
|
490 |
st.download_button(
|
491 |
label="Export Exposures",
|
492 |
+
data=st.session_state.team_freq.to_csv().encode('utf-8'),
|
493 |
+
file_name='team_freq.csv',
|
494 |
mime='text/csv',
|
495 |
+
key='team'
|
496 |
)
|