Spaces:
Sleeping
Sleeping
James McCool
commited on
Commit
·
2e35766
1
Parent(s):
7886731
Refactor ownership calculations in app.py to streamline dupes logic for FanDuel and DraftKings. Introduced new columns for 'own_product', 'avg_own_rank', and 'dupes_calc' to enhance clarity and accuracy in ownership metrics. This update improves the precision of player ownership analysis and contest lineup simulations.
Browse files
app.py
CHANGED
@@ -568,35 +568,35 @@ with tab1:
|
|
568 |
# Calculate Dupes column for Fanduel
|
569 |
if sim_site_var1 == 'Fanduel':
|
570 |
# Calculate ownership product and convert to probability
|
571 |
-
own_product = (Sim_Winner_Frame[own_columns].product(axis=1)) + 0.0001
|
572 |
|
573 |
# Calculate average of ownership percent rank columns
|
574 |
-
avg_own_rank = Sim_Winner_Frame[dup_count_columns].mean(axis=1)
|
575 |
|
576 |
# Calculate dupes formula
|
577 |
-
dupes_calc = ((own_product * avg_own_rank) * Contest_Size) + ((Sim_Winner_Frame['salary'] - 59800) / 100)
|
578 |
|
579 |
# Round and handle negative values
|
580 |
Sim_Winner_Frame['Dupes'] = np.where(
|
581 |
-
np.round(dupes_calc, 0) <= 0,
|
582 |
0,
|
583 |
-
np.round(dupes_calc, 0) - 1
|
584 |
)
|
585 |
elif sim_site_var1 == 'Draftkings':
|
586 |
# Calculate ownership product and convert to probability
|
587 |
-
own_product = (Sim_Winner_Frame[own_columns].product(axis=1))
|
588 |
|
589 |
# Calculate average of ownership percent rank columns
|
590 |
-
avg_own_rank = Sim_Winner_Frame[dup_count_columns].mean(axis=1)
|
591 |
|
592 |
# Calculate dupes formula
|
593 |
-
dupes_calc = ((own_product * avg_own_rank) * Contest_Size) + ((Sim_Winner_Frame['salary'] - 49800) / 100)
|
594 |
|
595 |
# Round and handle negative values
|
596 |
Sim_Winner_Frame['Dupes'] = np.where(
|
597 |
-
np.round(dupes_calc, 0) <= 0,
|
598 |
0,
|
599 |
-
np.round(dupes_calc, 0) - 1
|
600 |
)
|
601 |
#Sim_Winner_Frame = Sim_Winner_Frame.drop(columns=dup_count_columns)
|
602 |
|
|
|
568 |
# Calculate Dupes column for Fanduel
|
569 |
if sim_site_var1 == 'Fanduel':
|
570 |
# Calculate ownership product and convert to probability
|
571 |
+
Sim_Winner_Frame['own_product'] = (Sim_Winner_Frame[own_columns].product(axis=1)) + 0.0001
|
572 |
|
573 |
# Calculate average of ownership percent rank columns
|
574 |
+
Sim_Winner_Frame['avg_own_rank'] = Sim_Winner_Frame[dup_count_columns].mean(axis=1)
|
575 |
|
576 |
# Calculate dupes formula
|
577 |
+
Sim_Winner_Frame['dupes_calc'] = ((Sim_Winner_Frame['own_product'] * Sim_Winner_Frame['avg_own_rank']) * Contest_Size) + ((Sim_Winner_Frame['salary'] - 59800) / 100)
|
578 |
|
579 |
# Round and handle negative values
|
580 |
Sim_Winner_Frame['Dupes'] = np.where(
|
581 |
+
np.round(Sim_Winner_Frame['dupes_calc'], 0) <= 0,
|
582 |
0,
|
583 |
+
np.round(Sim_Winner_Frame['dupes_calc'], 0) - 1
|
584 |
)
|
585 |
elif sim_site_var1 == 'Draftkings':
|
586 |
# Calculate ownership product and convert to probability
|
587 |
+
Sim_Winner_Frame['own_product'] = (Sim_Winner_Frame[own_columns].product(axis=1))
|
588 |
|
589 |
# Calculate average of ownership percent rank columns
|
590 |
+
Sim_Winner_Frame['avg_own_rank'] = Sim_Winner_Frame[dup_count_columns].mean(axis=1)
|
591 |
|
592 |
# Calculate dupes formula
|
593 |
+
Sim_Winner_Frame['dupes_calc'] = ((Sim_Winner_Frame['own_product'] * Sim_Winner_Frame['avg_own_rank']) * Contest_Size) + ((Sim_Winner_Frame['salary'] - 49800) / 100)
|
594 |
|
595 |
# Round and handle negative values
|
596 |
Sim_Winner_Frame['Dupes'] = np.where(
|
597 |
+
np.round(Sim_Winner_Frame['dupes_calc'], 0) <= 0,
|
598 |
0,
|
599 |
+
np.round(Sim_Winner_Frame['dupes_calc'], 0) - 1
|
600 |
)
|
601 |
#Sim_Winner_Frame = Sim_Winner_Frame.drop(columns=dup_count_columns)
|
602 |
|