Spaces:
Running
Running
James McCool
commited on
Commit
·
fc8cc73
1
Parent(s):
72c894a
Enhance summary statistics generation in app.py: implement conditional logic for slate type (Regular or Showdown) to accurately compute metrics for Draftkings and Fanduel, improving data representation and user experience.
Browse files
app.py
CHANGED
@@ -516,49 +516,96 @@ with tab2:
|
|
516 |
if 'working_seed' in st.session_state:
|
517 |
# Create a new dataframe with summary statistics
|
518 |
if site_var1 == 'Draftkings':
|
519 |
-
|
|
|
520 |
'Metric': ['Min', 'Average', 'Max', 'STDdev'],
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
540 |
elif site_var1 == 'Fanduel':
|
541 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
542 |
'Metric': ['Min', 'Average', 'Max', 'STDdev'],
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
562 |
|
563 |
# Set the index of the summary dataframe as the "Metric" column
|
564 |
summary_df = summary_df.set_index('Metric')
|
@@ -575,10 +622,16 @@ with tab2:
|
|
575 |
tab1, tab2 = st.tabs(["Display Frequency", "Seed Frame Frequency"])
|
576 |
with tab1:
|
577 |
if 'data_export_display' in st.session_state:
|
578 |
-
if
|
579 |
-
|
580 |
-
|
581 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
582 |
|
583 |
# Flatten the DataFrame and count unique values
|
584 |
value_counts = player_columns.values.flatten().tolist()
|
@@ -609,10 +662,16 @@ with tab2:
|
|
609 |
)
|
610 |
with tab2:
|
611 |
if 'working_seed' in st.session_state:
|
612 |
-
if
|
613 |
-
|
614 |
-
|
615 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
616 |
|
617 |
# Flatten the DataFrame and count unique values
|
618 |
value_counts = player_columns.flatten().tolist()
|
|
|
516 |
if 'working_seed' in st.session_state:
|
517 |
# Create a new dataframe with summary statistics
|
518 |
if site_var1 == 'Draftkings':
|
519 |
+
if slate_type_var1 == 'Regular':
|
520 |
+
summary_df = pd.DataFrame({
|
521 |
'Metric': ['Min', 'Average', 'Max', 'STDdev'],
|
522 |
+
'Salary': [
|
523 |
+
np.min(st.session_state.working_seed[:,8]),
|
524 |
+
np.mean(st.session_state.working_seed[:,8]),
|
525 |
+
np.max(st.session_state.working_seed[:,8]),
|
526 |
+
np.std(st.session_state.working_seed[:,8])
|
527 |
+
],
|
528 |
+
'Proj': [
|
529 |
+
np.min(st.session_state.working_seed[:,9]),
|
530 |
+
np.mean(st.session_state.working_seed[:,9]),
|
531 |
+
np.max(st.session_state.working_seed[:,9]),
|
532 |
+
np.std(st.session_state.working_seed[:,9])
|
533 |
+
],
|
534 |
+
'Own': [
|
535 |
+
np.min(st.session_state.working_seed[:,14]),
|
536 |
+
np.mean(st.session_state.working_seed[:,14]),
|
537 |
+
np.max(st.session_state.working_seed[:,14]),
|
538 |
+
np.std(st.session_state.working_seed[:,14])
|
539 |
+
]
|
540 |
+
})
|
541 |
+
elif slate_type_var1 == 'Showdown':
|
542 |
+
summary_df = pd.DataFrame({
|
543 |
+
'Metric': ['Min', 'Average', 'Max', 'STDdev'],
|
544 |
+
'Salary': [
|
545 |
+
np.min(st.session_state.working_seed[:,6]),
|
546 |
+
np.mean(st.session_state.working_seed[:,6]),
|
547 |
+
np.max(st.session_state.working_seed[:,6]),
|
548 |
+
np.std(st.session_state.working_seed[:,6])
|
549 |
+
],
|
550 |
+
'Proj': [
|
551 |
+
np.min(st.session_state.working_seed[:,7]),
|
552 |
+
np.mean(st.session_state.working_seed[:,7]),
|
553 |
+
np.max(st.session_state.working_seed[:,7]),
|
554 |
+
np.std(st.session_state.working_seed[:,7])
|
555 |
+
],
|
556 |
+
'Own': [
|
557 |
+
np.min(st.session_state.working_seed[:,12]),
|
558 |
+
np.mean(st.session_state.working_seed[:,12]),
|
559 |
+
np.max(st.session_state.working_seed[:,12]),
|
560 |
+
np.std(st.session_state.working_seed[:,12])
|
561 |
+
]
|
562 |
+
})
|
563 |
+
|
564 |
elif site_var1 == 'Fanduel':
|
565 |
+
if slate_type_var1 == 'Regular':
|
566 |
+
summary_df = pd.DataFrame({
|
567 |
+
'Metric': ['Min', 'Average', 'Max', 'STDdev'],
|
568 |
+
'Salary': [
|
569 |
+
np.min(st.session_state.working_seed[:,9]),
|
570 |
+
np.mean(st.session_state.working_seed[:,9]),
|
571 |
+
np.max(st.session_state.working_seed[:,9]),
|
572 |
+
np.std(st.session_state.working_seed[:,9])
|
573 |
+
],
|
574 |
+
'Proj': [
|
575 |
+
np.min(st.session_state.working_seed[:,10]),
|
576 |
+
np.mean(st.session_state.working_seed[:,10]),
|
577 |
+
np.max(st.session_state.working_seed[:,10]),
|
578 |
+
np.std(st.session_state.working_seed[:,10])
|
579 |
+
],
|
580 |
+
'Own': [
|
581 |
+
np.min(st.session_state.working_seed[:,15]),
|
582 |
+
np.mean(st.session_state.working_seed[:,15]),
|
583 |
+
np.max(st.session_state.working_seed[:,15]),
|
584 |
+
np.std(st.session_state.working_seed[:,15])
|
585 |
+
]
|
586 |
+
})
|
587 |
+
elif slate_type_var1 == 'Showdown':
|
588 |
+
summary_df = pd.DataFrame({
|
589 |
'Metric': ['Min', 'Average', 'Max', 'STDdev'],
|
590 |
+
'Salary': [
|
591 |
+
np.min(st.session_state.working_seed[:,6]),
|
592 |
+
np.mean(st.session_state.working_seed[:,6]),
|
593 |
+
np.max(st.session_state.working_seed[:,6]),
|
594 |
+
np.std(st.session_state.working_seed[:,6])
|
595 |
+
],
|
596 |
+
'Proj': [
|
597 |
+
np.min(st.session_state.working_seed[:,7]),
|
598 |
+
np.mean(st.session_state.working_seed[:,7]),
|
599 |
+
np.max(st.session_state.working_seed[:,7]),
|
600 |
+
np.std(st.session_state.working_seed[:,7])
|
601 |
+
],
|
602 |
+
'Own': [
|
603 |
+
np.min(st.session_state.working_seed[:,12]),
|
604 |
+
np.mean(st.session_state.working_seed[:,12]),
|
605 |
+
np.max(st.session_state.working_seed[:,12]),
|
606 |
+
np.std(st.session_state.working_seed[:,12])
|
607 |
+
]
|
608 |
+
})
|
609 |
|
610 |
# Set the index of the summary dataframe as the "Metric" column
|
611 |
summary_df = summary_df.set_index('Metric')
|
|
|
622 |
tab1, tab2 = st.tabs(["Display Frequency", "Seed Frame Frequency"])
|
623 |
with tab1:
|
624 |
if 'data_export_display' in st.session_state:
|
625 |
+
if slate_type_var1 == 'Regular':
|
626 |
+
if site_var1 == 'Draftkings':
|
627 |
+
player_columns = st.session_state.data_export_display.iloc[:, :8]
|
628 |
+
elif site_var1 == 'Fanduel':
|
629 |
+
player_columns = st.session_state.data_export_display.iloc[:, :9]
|
630 |
+
elif slate_type_var1 == 'Showdown':
|
631 |
+
if site_var1 == 'Draftkings':
|
632 |
+
player_columns = st.session_state.data_export_display.iloc[:, :5]
|
633 |
+
elif site_var1 == 'Fanduel':
|
634 |
+
player_columns = st.session_state.data_export_display.iloc[:, :5]
|
635 |
|
636 |
# Flatten the DataFrame and count unique values
|
637 |
value_counts = player_columns.values.flatten().tolist()
|
|
|
662 |
)
|
663 |
with tab2:
|
664 |
if 'working_seed' in st.session_state:
|
665 |
+
if slate_type_var1 == 'Regular':
|
666 |
+
if site_var1 == 'Draftkings':
|
667 |
+
player_columns = st.session_state.working_seed[:, :8]
|
668 |
+
elif site_var1 == 'Fanduel':
|
669 |
+
player_columns = st.session_state.working_seed[:, :9]
|
670 |
+
elif slate_type_var1 == 'Showdown':
|
671 |
+
if site_var1 == 'Draftkings':
|
672 |
+
player_columns = st.session_state.working_seed[:, :5]
|
673 |
+
elif site_var1 == 'Fanduel':
|
674 |
+
player_columns = st.session_state.working_seed[:, :5]
|
675 |
|
676 |
# Flatten the DataFrame and count unique values
|
677 |
value_counts = player_columns.flatten().tolist()
|