Spaces:
Build error
Build error
James McCool
commited on
Commit
·
1e2cd0a
1
Parent(s):
3ddd1d0
added trending FPPM
Browse files
app.py
CHANGED
|
@@ -47,9 +47,9 @@ def init_baselines():
|
|
| 47 |
raw_display = raw_display.reset_index(drop=True)
|
| 48 |
trend_table = raw_display[raw_display['PLAYER_NAME'] != ""]
|
| 49 |
trend_table.replace('', np.nan, inplace=True)
|
| 50 |
-
trend_table = trend_table[['PLAYER_NAME', 'Team', 'Position', 'FD_Position', 'L10 MIN', 'L10 Fantasy', 'L10 Ceiling', 'L10 FD_Fantasy',
|
| 51 |
-
'L10 FD_Ceiling', 'L5 MIN', 'L5 Fantasy', 'L5 Ceiling', 'L5 FD_Fantasy', 'L5 FD_Ceiling', 'L3 MIN', 'L3 Fantasy',
|
| 52 |
-
'L3 Ceiling', 'L3 FD_Fantasy', 'L3 FD_Ceiling', 'Trend Min', 'Trend Median', 'DK_Proj', 'Adj Median', 'Adj Ceiling',
|
| 53 |
'Trend FD_Median', 'FD_Proj', 'Adj FD_Median', 'Adj FD_Ceiling', 'DK_Salary', 'DK_Avg_Val', 'DK_Ceiling_Value',
|
| 54 |
'FD_Salary', 'FD_Avg_Val', 'FD_Ceiling_Value']]
|
| 55 |
trend_table['DK_Salary'] = trend_table['DK_Salary'].str.replace(',', '').astype(float)
|
|
@@ -64,24 +64,28 @@ def init_baselines():
|
|
| 64 |
dk_medians_table = trend_table[['PLAYER_NAME', 'Team', 'L10 Fantasy', 'L5 Fantasy', 'L3 Fantasy', 'Trend Median']]
|
| 65 |
|
| 66 |
fd_medians_table = trend_table[['PLAYER_NAME', 'Team', 'L10 FD_Fantasy', 'L5 FD_Fantasy', 'L3 FD_Fantasy', 'Trend FD_Median']]
|
|
|
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
dk_proj_medians_table = trend_table[['PLAYER_NAME', 'Team', 'Position', 'DK_Salary', 'DK_Proj', 'Adj Median', 'DK_Avg_Val', 'Adj Ceiling', 'DK_Ceiling_Value']]
|
| 69 |
|
| 70 |
fd_proj_medians_table = trend_table[['PLAYER_NAME', 'Team', 'FD_Position', 'FD_Salary', 'FD_Proj', 'Adj FD_Median', 'FD_Avg_Val', 'Adj FD_Ceiling', 'FD_Ceiling_Value']]
|
| 71 |
|
| 72 |
-
return trend_table, dk_minutes_table, fd_minutes_table, dk_medians_table, fd_medians_table, dk_proj_medians_table, fd_proj_medians_table
|
| 73 |
|
| 74 |
def convert_df_to_csv(df):
|
| 75 |
return df.to_csv().encode('utf-8')
|
| 76 |
|
| 77 |
-
trend_table, dk_minutes_table, fd_minutes_table, dk_medians_table, fd_medians_table, dk_proj_medians_table, fd_proj_medians_table = init_baselines()
|
| 78 |
|
| 79 |
col1, col2 = st.columns([1, 9])
|
| 80 |
with col1:
|
| 81 |
if st.button("Reset Data", key='reset1'):
|
| 82 |
st.cache_data.clear()
|
| 83 |
trend_table, dk_minutes_table, fd_minutes_table, dk_medians_table, fd_medians_table, dk_proj_medians_table, fd_proj_medians_table = init_baselines()
|
| 84 |
-
split_var1 = st.radio("What table would you like to view?", ('Minutes Trends', 'Fantasy Trends', 'Slate specific', 'Overall'), key='split_var1')
|
| 85 |
site_var1 = st.radio("What site would you like to view?", ('Draftkings', 'Fanduel'), key='site_var1')
|
| 86 |
if site_var1 == 'Draftkings':
|
| 87 |
trend_table = trend_table[['PLAYER_NAME', 'Team', 'Position', 'L10 MIN', 'L10 Fantasy', 'L10 Ceiling',
|
|
@@ -90,6 +94,7 @@ with col1:
|
|
| 90 |
'DK_Salary', 'DK_Avg_Val', 'DK_Ceiling_Value']]
|
| 91 |
minutes_table = dk_minutes_table
|
| 92 |
medians_table = dk_medians_table
|
|
|
|
| 93 |
proj_medians_table = dk_proj_medians_table
|
| 94 |
elif site_var1 == 'Fanduel':
|
| 95 |
trend_table = trend_table[['PLAYER_NAME', 'Team', 'FD_Position', 'L10 MIN', 'L10 FD_Fantasy',
|
|
@@ -98,13 +103,15 @@ with col1:
|
|
| 98 |
'FD_Salary', 'FD_Avg_Val', 'FD_Ceiling_Value']]
|
| 99 |
minutes_table = fd_minutes_table
|
| 100 |
medians_table = fd_medians_table
|
|
|
|
| 101 |
proj_medians_table = fd_proj_medians_table
|
| 102 |
-
trend_table = trend_table.set_axis(['PLAYER_NAME', 'Team', 'Position', 'L10 MIN', 'L10 Fantasy', 'L10 Ceiling',
|
| 103 |
-
'L5 MIN', 'L5 Fantasy', 'L5 Ceiling', 'L3 MIN', 'L3 Fantasy',
|
| 104 |
-
'L3 Ceiling', 'Trend Min', 'Trend Median', '
|
| 105 |
-
'
|
| 106 |
minutes_table = minutes_table.set_axis(['PLAYER_NAME', 'Team', 'L10 MIN', 'L5 MIN', 'L3 MIN', 'Trend Min'], axis=1)
|
| 107 |
medians_table = medians_table.set_axis(['PLAYER_NAME', 'Team', 'L10 Fantasy','L5 Fantasy', 'L3 Fantasy', 'Trend Median'], axis=1)
|
|
|
|
| 108 |
proj_medians_table = proj_medians_table.set_axis(['PLAYER_NAME', 'Team', 'Position', 'Salary', 'Proj',
|
| 109 |
'Adj Median', 'Avg_Val', 'Adj Ceiling', 'Ceiling_Value'], axis=1)
|
| 110 |
if split_var1 == 'Overall':
|
|
@@ -141,7 +148,16 @@ with col1:
|
|
| 141 |
team_var1 = st.multiselect('Which teams would you like to include in the tables?', options = view_var1, key='team_var1')
|
| 142 |
elif split_var2 == 'All':
|
| 143 |
team_var1 = view_var1
|
|
|
|
|
|
|
|
|
|
|
|
|
| 144 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 145 |
elif split_var1 == 'Slate specific':
|
| 146 |
view_var1 = trend_table.Team.values.tolist()
|
| 147 |
split_var2 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var2')
|
|
@@ -197,6 +213,17 @@ with col2:
|
|
| 197 |
mime='text/csv',
|
| 198 |
)
|
| 199 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
elif split_var1 == 'Slate specific':
|
| 201 |
table_display = proj_medians_table[proj_medians_table['Proj'] >= proj_var1[0]]
|
| 202 |
table_display = table_display[table_display['Proj'] <= proj_var1[1]]
|
|
|
|
| 47 |
raw_display = raw_display.reset_index(drop=True)
|
| 48 |
trend_table = raw_display[raw_display['PLAYER_NAME'] != ""]
|
| 49 |
trend_table.replace('', np.nan, inplace=True)
|
| 50 |
+
trend_table = trend_table[['PLAYER_NAME', 'Team', 'Position', 'FD_Position', 'L10 MIN', 'L10 Fantasy', 'L10 FPPM', 'L10 Ceiling', 'L10 FD_Fantasy',
|
| 51 |
+
'L10 FD_Ceiling', 'L5 MIN', 'L5 Fantasy', 'L5 FPPM', 'L5 Ceiling', 'L5 FD_Fantasy', 'L5 FD_Ceiling', 'L3 MIN', 'L3 Fantasy',
|
| 52 |
+
'L3 FPPM', 'L3 Ceiling', 'L3 FD_Fantasy', 'L3 FD_Ceiling', 'Trend Min', 'Trend Median', 'DK_Proj', 'Adj Median', 'Adj Ceiling',
|
| 53 |
'Trend FD_Median', 'FD_Proj', 'Adj FD_Median', 'Adj FD_Ceiling', 'DK_Salary', 'DK_Avg_Val', 'DK_Ceiling_Value',
|
| 54 |
'FD_Salary', 'FD_Avg_Val', 'FD_Ceiling_Value']]
|
| 55 |
trend_table['DK_Salary'] = trend_table['DK_Salary'].str.replace(',', '').astype(float)
|
|
|
|
| 64 |
dk_medians_table = trend_table[['PLAYER_NAME', 'Team', 'L10 Fantasy', 'L5 Fantasy', 'L3 Fantasy', 'Trend Median']]
|
| 65 |
|
| 66 |
fd_medians_table = trend_table[['PLAYER_NAME', 'Team', 'L10 FD_Fantasy', 'L5 FD_Fantasy', 'L3 FD_Fantasy', 'Trend FD_Median']]
|
| 67 |
+
|
| 68 |
+
dk_fppm_table = trend_table[['PLAYER_NAME', 'Team', 'L10 FPPM', 'L5 FPPM', 'L3 FPPM', 'Trend FPPM']]
|
| 69 |
+
|
| 70 |
+
fd_fppm_table = trend_table[['PLAYER_NAME', 'Team', 'L10 FPPM', 'L5 FPPM', 'L3 FPPM', 'Trend FPPM']]
|
| 71 |
|
| 72 |
dk_proj_medians_table = trend_table[['PLAYER_NAME', 'Team', 'Position', 'DK_Salary', 'DK_Proj', 'Adj Median', 'DK_Avg_Val', 'Adj Ceiling', 'DK_Ceiling_Value']]
|
| 73 |
|
| 74 |
fd_proj_medians_table = trend_table[['PLAYER_NAME', 'Team', 'FD_Position', 'FD_Salary', 'FD_Proj', 'Adj FD_Median', 'FD_Avg_Val', 'Adj FD_Ceiling', 'FD_Ceiling_Value']]
|
| 75 |
|
| 76 |
+
return trend_table, dk_minutes_table, fd_minutes_table, dk_medians_table, fd_medians_table, dk_fppm_table, fd_fppm_table, dk_proj_medians_table, fd_proj_medians_table
|
| 77 |
|
| 78 |
def convert_df_to_csv(df):
|
| 79 |
return df.to_csv().encode('utf-8')
|
| 80 |
|
| 81 |
+
trend_table, dk_minutes_table, fd_minutes_table, dk_medians_table, fd_medians_table, dk_fppm_table, fd_fppm_table, dk_proj_medians_table, fd_proj_medians_table = init_baselines()
|
| 82 |
|
| 83 |
col1, col2 = st.columns([1, 9])
|
| 84 |
with col1:
|
| 85 |
if st.button("Reset Data", key='reset1'):
|
| 86 |
st.cache_data.clear()
|
| 87 |
trend_table, dk_minutes_table, fd_minutes_table, dk_medians_table, fd_medians_table, dk_proj_medians_table, fd_proj_medians_table = init_baselines()
|
| 88 |
+
split_var1 = st.radio("What table would you like to view?", ('Minutes Trends', 'Fantasy Trends', 'FPPM Trends', 'Slate specific', 'Overall'), key='split_var1')
|
| 89 |
site_var1 = st.radio("What site would you like to view?", ('Draftkings', 'Fanduel'), key='site_var1')
|
| 90 |
if site_var1 == 'Draftkings':
|
| 91 |
trend_table = trend_table[['PLAYER_NAME', 'Team', 'Position', 'L10 MIN', 'L10 Fantasy', 'L10 Ceiling',
|
|
|
|
| 94 |
'DK_Salary', 'DK_Avg_Val', 'DK_Ceiling_Value']]
|
| 95 |
minutes_table = dk_minutes_table
|
| 96 |
medians_table = dk_medians_table
|
| 97 |
+
fppm_table = dk_fppm_table
|
| 98 |
proj_medians_table = dk_proj_medians_table
|
| 99 |
elif site_var1 == 'Fanduel':
|
| 100 |
trend_table = trend_table[['PLAYER_NAME', 'Team', 'FD_Position', 'L10 MIN', 'L10 FD_Fantasy',
|
|
|
|
| 103 |
'FD_Salary', 'FD_Avg_Val', 'FD_Ceiling_Value']]
|
| 104 |
minutes_table = fd_minutes_table
|
| 105 |
medians_table = fd_medians_table
|
| 106 |
+
fppm_table = fd_fppm_table
|
| 107 |
proj_medians_table = fd_proj_medians_table
|
| 108 |
+
trend_table = trend_table.set_axis(['PLAYER_NAME', 'Team', 'Position', 'L10 MIN', 'L10 Fantasy', 'L10 FPPM', 'L10 Ceiling',
|
| 109 |
+
'L5 MIN', 'L5 Fantasy', 'L5 FPPM', 'L5 Ceiling', 'L3 MIN', 'L3 Fantasy',
|
| 110 |
+
'L3 FPPM', 'L3 Ceiling', 'Trend Min', 'Trend Median', 'FD_Proj', 'Adj FD_Median', 'Adj FD_Ceiling',
|
| 111 |
+
'FD_Salary', 'FD_Avg_Val', 'FD_Ceiling_Value'], axis=1)
|
| 112 |
minutes_table = minutes_table.set_axis(['PLAYER_NAME', 'Team', 'L10 MIN', 'L5 MIN', 'L3 MIN', 'Trend Min'], axis=1)
|
| 113 |
medians_table = medians_table.set_axis(['PLAYER_NAME', 'Team', 'L10 Fantasy','L5 Fantasy', 'L3 Fantasy', 'Trend Median'], axis=1)
|
| 114 |
+
fppm_table = fppm_table.set_axis(['PLAYER_NAME', 'Team', 'L10 FPPM', 'L5 FPPM', 'L3 FPPM', 'Trend FPPM'], axis=1)
|
| 115 |
proj_medians_table = proj_medians_table.set_axis(['PLAYER_NAME', 'Team', 'Position', 'Salary', 'Proj',
|
| 116 |
'Adj Median', 'Avg_Val', 'Adj Ceiling', 'Ceiling_Value'], axis=1)
|
| 117 |
if split_var1 == 'Overall':
|
|
|
|
| 148 |
team_var1 = st.multiselect('Which teams would you like to include in the tables?', options = view_var1, key='team_var1')
|
| 149 |
elif split_var2 == 'All':
|
| 150 |
team_var1 = view_var1
|
| 151 |
+
|
| 152 |
+
elif split_var1 == 'FPPM Trends':
|
| 153 |
+
view_var1 = trend_table.Team.values.tolist()
|
| 154 |
+
split_var2 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var2')
|
| 155 |
|
| 156 |
+
if split_var2 == 'Specific Teams':
|
| 157 |
+
team_var1 = st.multiselect('Which teams would you like to include in the tables?', options = view_var1, key='team_var1')
|
| 158 |
+
elif split_var2 == 'All':
|
| 159 |
+
team_var1 = view_var1
|
| 160 |
+
|
| 161 |
elif split_var1 == 'Slate specific':
|
| 162 |
view_var1 = trend_table.Team.values.tolist()
|
| 163 |
split_var2 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var2')
|
|
|
|
| 213 |
mime='text/csv',
|
| 214 |
)
|
| 215 |
|
| 216 |
+
elif split_var1 == 'FPPM Trends':
|
| 217 |
+
table_display = fppm_table[fppm_table['Team'].isin(team_var1)]
|
| 218 |
+
table_display = table_display.set_index('PLAYER_NAME')
|
| 219 |
+
st.dataframe(table_display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
| 220 |
+
st.download_button(
|
| 221 |
+
label="Export Trending Numbers",
|
| 222 |
+
data=convert_df_to_csv(table_display),
|
| 223 |
+
file_name='Trending_export.csv',
|
| 224 |
+
mime='text/csv',
|
| 225 |
+
)
|
| 226 |
+
|
| 227 |
elif split_var1 == 'Slate specific':
|
| 228 |
table_display = proj_medians_table[proj_medians_table['Proj'] >= proj_var1[0]]
|
| 229 |
table_display = table_display[table_display['Proj'] <= proj_var1[1]]
|