Spaces:
Running
Running
James McCool
commited on
Commit
·
7f643e6
1
Parent(s):
70cfb96
Refactor ownership value calculations in app.py to use updated column indices for DraftKings and FanDuel, and enhance summary statistics display based on slate type, improving data accuracy and user experience.
Browse files
app.py
CHANGED
@@ -421,8 +421,8 @@ with tab3:
|
|
421 |
player_salaries = dict(zip(raw_baselines['Player'], raw_baselines['Salary']))
|
422 |
column_names = dk_sd_columns
|
423 |
# Get the minimum and maximum ownership values from dk_lineups
|
424 |
-
min_own = np.min(dk_lineups[:,
|
425 |
-
max_own = np.max(dk_lineups[:,
|
426 |
|
427 |
|
428 |
player_var1 = st.radio("Do you want a frame with specific Players?", ('Full Slate', 'Specific Players'), key='player_var1')
|
@@ -441,8 +441,8 @@ with tab3:
|
|
441 |
player_salaries = dict(zip(raw_baselines['Player'], raw_baselines['Salary']))
|
442 |
column_names = fd_sd_columns
|
443 |
# Get the minimum and maximum ownership values from dk_lineups
|
444 |
-
min_own = np.min(fd_lineups[:,
|
445 |
-
max_own = np.max(fd_lineups[:,
|
446 |
|
447 |
|
448 |
player_var1 = st.radio("Do you want a frame with specific Players?", ('Full Slate', 'Specific Players'), key='player_var1')
|
@@ -455,11 +455,17 @@ with tab3:
|
|
455 |
name_export = pd.DataFrame(st.session_state.working_seed.copy(), columns=column_names)
|
456 |
data_export = pd.DataFrame(st.session_state.working_seed.copy(), columns=column_names)
|
457 |
if site_var == 'Draftkings':
|
458 |
-
|
|
|
|
|
|
|
459 |
for col_idx in map_columns:
|
460 |
data_export[col_idx] = data_export[col_idx].map(dk_id_map)
|
461 |
elif site_var == 'Fanduel':
|
462 |
-
|
|
|
|
|
|
|
463 |
for col_idx in map_columns:
|
464 |
data_export[col_idx] = data_export[col_idx].map(fd_id_map)
|
465 |
st.download_button(
|
@@ -512,11 +518,17 @@ with tab3:
|
|
512 |
export_file = st.session_state.data_export_display.copy()
|
513 |
name_export = st.session_state.data_export_display.copy()
|
514 |
if site_var == 'Draftkings':
|
515 |
-
|
|
|
|
|
|
|
516 |
for col_idx in map_columns:
|
517 |
export_file[col_idx] = export_file[col_idx].map(dk_id_map)
|
518 |
elif site_var == 'Fanduel':
|
519 |
-
|
|
|
|
|
|
|
520 |
for col_idx in map_columns:
|
521 |
export_file[col_idx] = export_file[col_idx].map(fd_id_map)
|
522 |
|
@@ -544,63 +556,64 @@ with tab3:
|
|
544 |
)
|
545 |
|
546 |
with st.container():
|
547 |
-
if '
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
-
|
601 |
-
|
602 |
-
|
603 |
-
|
|
|
604 |
|
605 |
with st.container():
|
606 |
tab1, tab2 = st.tabs(["Display Frequency", "Seed Frame Frequency"])
|
|
|
421 |
player_salaries = dict(zip(raw_baselines['Player'], raw_baselines['Salary']))
|
422 |
column_names = dk_sd_columns
|
423 |
# Get the minimum and maximum ownership values from dk_lineups
|
424 |
+
min_own = np.min(dk_lineups[:,12])
|
425 |
+
max_own = np.max(dk_lineups[:,11])
|
426 |
|
427 |
|
428 |
player_var1 = st.radio("Do you want a frame with specific Players?", ('Full Slate', 'Specific Players'), key='player_var1')
|
|
|
441 |
player_salaries = dict(zip(raw_baselines['Player'], raw_baselines['Salary']))
|
442 |
column_names = fd_sd_columns
|
443 |
# Get the minimum and maximum ownership values from dk_lineups
|
444 |
+
min_own = np.min(fd_lineups[:,12])
|
445 |
+
max_own = np.max(fd_lineups[:,11])
|
446 |
|
447 |
|
448 |
player_var1 = st.radio("Do you want a frame with specific Players?", ('Full Slate', 'Specific Players'), key='player_var1')
|
|
|
455 |
name_export = pd.DataFrame(st.session_state.working_seed.copy(), columns=column_names)
|
456 |
data_export = pd.DataFrame(st.session_state.working_seed.copy(), columns=column_names)
|
457 |
if site_var == 'Draftkings':
|
458 |
+
if slate_type_var3 == 'Regular':
|
459 |
+
map_columns = ['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']
|
460 |
+
elif slate_type_var3 == 'Showdown':
|
461 |
+
map_columns = ['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5']
|
462 |
for col_idx in map_columns:
|
463 |
data_export[col_idx] = data_export[col_idx].map(dk_id_map)
|
464 |
elif site_var == 'Fanduel':
|
465 |
+
if slate_type_var3 == 'Regular':
|
466 |
+
map_columns = ['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL']
|
467 |
+
elif slate_type_var3 == 'Showdown':
|
468 |
+
map_columns = ['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4']
|
469 |
for col_idx in map_columns:
|
470 |
data_export[col_idx] = data_export[col_idx].map(fd_id_map)
|
471 |
st.download_button(
|
|
|
518 |
export_file = st.session_state.data_export_display.copy()
|
519 |
name_export = st.session_state.data_export_display.copy()
|
520 |
if site_var == 'Draftkings':
|
521 |
+
if slate_type_var3 == 'Regular':
|
522 |
+
map_columns = ['SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']
|
523 |
+
elif slate_type_var3 == 'Showdown':
|
524 |
+
map_columns = ['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4', 'FLEX5']
|
525 |
for col_idx in map_columns:
|
526 |
export_file[col_idx] = export_file[col_idx].map(dk_id_map)
|
527 |
elif site_var == 'Fanduel':
|
528 |
+
if slate_type_var3 == 'Regular':
|
529 |
+
map_columns = ['P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL']
|
530 |
+
elif slate_type_var3 == 'Showdown':
|
531 |
+
map_columns = ['CPT', 'FLEX1', 'FLEX2', 'FLEX3', 'FLEX4']
|
532 |
for col_idx in map_columns:
|
533 |
export_file[col_idx] = export_file[col_idx].map(fd_id_map)
|
534 |
|
|
|
556 |
)
|
557 |
|
558 |
with st.container():
|
559 |
+
if slate_type_var3 == 'Regular':
|
560 |
+
if 'working_seed' in st.session_state:
|
561 |
+
# Create a new dataframe with summary statistics
|
562 |
+
if site_var == 'Draftkings':
|
563 |
+
summary_df = pd.DataFrame({
|
564 |
+
'Metric': ['Min', 'Average', 'Max', 'STDdev'],
|
565 |
+
'Salary': [
|
566 |
+
np.min(st.session_state.working_seed[:,10]),
|
567 |
+
np.mean(st.session_state.working_seed[:,10]),
|
568 |
+
np.max(st.session_state.working_seed[:,10]),
|
569 |
+
np.std(st.session_state.working_seed[:,10])
|
570 |
+
],
|
571 |
+
'Proj': [
|
572 |
+
np.min(st.session_state.working_seed[:,11]),
|
573 |
+
np.mean(st.session_state.working_seed[:,11]),
|
574 |
+
np.max(st.session_state.working_seed[:,11]),
|
575 |
+
np.std(st.session_state.working_seed[:,11])
|
576 |
+
],
|
577 |
+
'Own': [
|
578 |
+
np.min(st.session_state.working_seed[:,16]),
|
579 |
+
np.mean(st.session_state.working_seed[:,16]),
|
580 |
+
np.max(st.session_state.working_seed[:,16]),
|
581 |
+
np.std(st.session_state.working_seed[:,16])
|
582 |
+
]
|
583 |
+
})
|
584 |
+
elif site_var == 'Fanduel':
|
585 |
+
summary_df = pd.DataFrame({
|
586 |
+
'Metric': ['Min', 'Average', 'Max', 'STDdev'],
|
587 |
+
'Salary': [
|
588 |
+
np.min(st.session_state.working_seed[:,9]),
|
589 |
+
np.mean(st.session_state.working_seed[:,9]),
|
590 |
+
np.max(st.session_state.working_seed[:,9]),
|
591 |
+
np.std(st.session_state.working_seed[:,9])
|
592 |
+
],
|
593 |
+
'Proj': [
|
594 |
+
np.min(st.session_state.working_seed[:,10]),
|
595 |
+
np.mean(st.session_state.working_seed[:,10]),
|
596 |
+
np.max(st.session_state.working_seed[:,10]),
|
597 |
+
np.std(st.session_state.working_seed[:,10])
|
598 |
+
],
|
599 |
+
'Own': [
|
600 |
+
np.min(st.session_state.working_seed[:,15]),
|
601 |
+
np.mean(st.session_state.working_seed[:,15]),
|
602 |
+
np.max(st.session_state.working_seed[:,15]),
|
603 |
+
np.std(st.session_state.working_seed[:,15])
|
604 |
+
]
|
605 |
+
})
|
606 |
+
|
607 |
+
# Set the index of the summary dataframe as the "Metric" column
|
608 |
+
summary_df = summary_df.set_index('Metric')
|
609 |
+
|
610 |
+
# Display the summary dataframe
|
611 |
+
st.subheader("Optimal Statistics")
|
612 |
+
st.dataframe(summary_df.style.format({
|
613 |
+
'Salary': '{:.2f}',
|
614 |
+
'Proj': '{:.2f}',
|
615 |
+
'Own': '{:.2f}'
|
616 |
+
}).background_gradient(cmap='RdYlGn', axis=0, subset=['Salary', 'Proj', 'Own']), use_container_width=True)
|
617 |
|
618 |
with st.container():
|
619 |
tab1, tab2 = st.tabs(["Display Frequency", "Seed Frame Frequency"])
|