Spaces:
Running
Running
James McCool
commited on
Commit
·
132cb49
1
Parent(s):
025741f
Adding position filtering for all tables
Browse files- src/streamlit_app.py +33 -12
src/streamlit_app.py
CHANGED
|
@@ -35,17 +35,17 @@ def init_baselines():
|
|
| 35 |
data_cols = trend_table.columns.drop(['PLAYER_NAME', 'Team', 'Position', 'FD_Position'])
|
| 36 |
trend_table[data_cols] = trend_table[data_cols].apply(pd.to_numeric, errors='coerce')
|
| 37 |
|
| 38 |
-
dk_minutes_table = trend_table[['PLAYER_NAME', 'Team', 'Season MIN', 'L10 MIN', 'L5 MIN', 'L3 MIN', 'Trend Min']]
|
| 39 |
|
| 40 |
-
fd_minutes_table = trend_table[['PLAYER_NAME', 'Team', 'Season MIN', 'L10 MIN', 'L5 MIN', 'L3 MIN', 'Trend Min']]
|
| 41 |
|
| 42 |
-
dk_medians_table = trend_table[['PLAYER_NAME', 'Team', 'Season Fantasy', 'L10 Fantasy', 'L5 Fantasy', 'L3 Fantasy', 'Trend Median']]
|
| 43 |
|
| 44 |
-
fd_medians_table = trend_table[['PLAYER_NAME', 'Team', 'Season FD_Fantasy', 'L10 FD_Fantasy', 'L5 FD_Fantasy', 'L3 FD_Fantasy', 'Trend FD_Median']]
|
| 45 |
|
| 46 |
-
dk_fppm_table = trend_table[['PLAYER_NAME', 'Team', 'Season FPPM', 'L10 FPPM', 'L5 FPPM', 'L3 FPPM', 'Trend FPPM']]
|
| 47 |
|
| 48 |
-
fd_fppm_table = trend_table[['PLAYER_NAME', 'Team', 'Season FPPM', 'L10 FPPM', 'L5 FPPM', 'L3 FPPM', 'Trend FPPM']]
|
| 49 |
|
| 50 |
dk_proj_medians_table = trend_table[['PLAYER_NAME', 'Team', 'Position', 'DK_Salary', 'DK_Proj', 'Adj Median', 'DK_Avg_Val', 'Adj Ceiling', 'DK_Ceiling_Value']]
|
| 51 |
|
|
@@ -84,9 +84,9 @@ with col1:
|
|
| 84 |
trend_table = trend_table.set_axis(['PLAYER_NAME', 'Team', 'Position', 'Season MIN', 'L10 MIN', 'L5 MIN', 'L3 MIN', 'Trend Min', 'Season Fantasy', 'L10 Fantasy', 'L5 Fantasy', 'L3 Fantasy',
|
| 85 |
'Trend Median', 'Season FPPM', 'L10 FPPM', 'L5 FPPM', 'L3 FPPM', 'Trend FPPM', 'DK_Proj', 'Adj Median', 'Adj Ceiling',
|
| 86 |
'Salary', 'Avg_Val', 'Ceiling_Value'], axis=1)
|
| 87 |
-
minutes_table = minutes_table.set_axis(['PLAYER_NAME', 'Team', 'Season MIN', 'L10 MIN', 'L5 MIN', 'L3 MIN', 'Trend Min'], axis=1)
|
| 88 |
-
medians_table = medians_table.set_axis(['PLAYER_NAME', 'Team', 'Season Fantasy', 'L10 Fantasy', 'L5 Fantasy', 'L3 Fantasy', 'Trend Median'], axis=1)
|
| 89 |
-
fppm_table = fppm_table.set_axis(['PLAYER_NAME', 'Team', 'Season FPPM', 'L10 FPPM', 'L5 FPPM', 'L3 FPPM', 'Trend FPPM'], axis=1)
|
| 90 |
proj_medians_table = proj_medians_table.set_axis(['PLAYER_NAME', 'Team', 'Position', 'Salary', 'Proj',
|
| 91 |
'Adj Median', 'Avg_Val', 'Adj Ceiling', 'Ceiling_Value'], axis=1)
|
| 92 |
if split_var1 == 'Overall':
|
|
@@ -115,6 +115,12 @@ with col1:
|
|
| 115 |
elif split_var2 == 'All':
|
| 116 |
team_var1 = view_var1
|
| 117 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 118 |
elif split_var1 == 'Fantasy Trends':
|
| 119 |
view_var1 = trend_table.Team.values.tolist()
|
| 120 |
split_var2 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var2')
|
|
@@ -123,6 +129,12 @@ with col1:
|
|
| 123 |
team_var1 = st.multiselect('Which teams would you like to include in the tables?', options = view_var1, key='team_var1')
|
| 124 |
elif split_var2 == 'All':
|
| 125 |
team_var1 = view_var1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
|
| 127 |
elif split_var1 == 'FPPM Trends':
|
| 128 |
view_var1 = trend_table.Team.values.tolist()
|
|
@@ -132,6 +144,12 @@ with col1:
|
|
| 132 |
team_var1 = st.multiselect('Which teams would you like to include in the tables?', options = view_var1, key='team_var1')
|
| 133 |
elif split_var2 == 'All':
|
| 134 |
team_var1 = view_var1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
|
| 136 |
elif split_var1 == 'Slate specific':
|
| 137 |
view_var1 = trend_table.Team.values.tolist()
|
|
@@ -142,10 +160,10 @@ with col1:
|
|
| 142 |
elif split_var2 == 'All':
|
| 143 |
team_var1 = view_var1
|
| 144 |
|
| 145 |
-
|
| 146 |
-
if
|
| 147 |
pos_var1 = st.multiselect('Which positions would you like to include in the tables?', options = ['PG', 'SG', 'SF', 'PF', 'C'], key='pos_var1')
|
| 148 |
-
elif
|
| 149 |
pos_var1 = ['PG', 'SG', 'SF', 'PF', 'C']
|
| 150 |
|
| 151 |
proj_var1 = st.slider("Is there a certain projection range you want to view?", 0, 100, (10, 100), key='proj_var1')
|
|
@@ -168,6 +186,7 @@ with col2:
|
|
| 168 |
|
| 169 |
elif split_var1 == 'Minutes Trends':
|
| 170 |
table_display = minutes_table[minutes_table['Team'].isin(team_var1)]
|
|
|
|
| 171 |
table_display = table_display.set_index('PLAYER_NAME')
|
| 172 |
st.dataframe(table_display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
| 173 |
st.download_button(
|
|
@@ -179,6 +198,7 @@ with col2:
|
|
| 179 |
|
| 180 |
elif split_var1 == 'Fantasy Trends':
|
| 181 |
table_display = medians_table[medians_table['Team'].isin(team_var1)]
|
|
|
|
| 182 |
table_display = table_display.set_index('PLAYER_NAME')
|
| 183 |
st.dataframe(table_display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
| 184 |
st.download_button(
|
|
@@ -190,6 +210,7 @@ with col2:
|
|
| 190 |
|
| 191 |
elif split_var1 == 'FPPM Trends':
|
| 192 |
table_display = fppm_table[fppm_table['Team'].isin(team_var1)]
|
|
|
|
| 193 |
table_display = table_display.set_index('PLAYER_NAME')
|
| 194 |
st.dataframe(table_display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
| 195 |
st.download_button(
|
|
|
|
| 35 |
data_cols = trend_table.columns.drop(['PLAYER_NAME', 'Team', 'Position', 'FD_Position'])
|
| 36 |
trend_table[data_cols] = trend_table[data_cols].apply(pd.to_numeric, errors='coerce')
|
| 37 |
|
| 38 |
+
dk_minutes_table = trend_table[['PLAYER_NAME', 'Team', 'Position', 'Season MIN', 'L10 MIN', 'L5 MIN', 'L3 MIN', 'Trend Min']]
|
| 39 |
|
| 40 |
+
fd_minutes_table = trend_table[['PLAYER_NAME', 'Team', 'FD_Position', 'Season MIN', 'L10 MIN', 'L5 MIN', 'L3 MIN', 'Trend Min']]
|
| 41 |
|
| 42 |
+
dk_medians_table = trend_table[['PLAYER_NAME', 'Team', 'Position', 'Season Fantasy', 'L10 Fantasy', 'L5 Fantasy', 'L3 Fantasy', 'Trend Median']]
|
| 43 |
|
| 44 |
+
fd_medians_table = trend_table[['PLAYER_NAME', 'Team', 'FD_Position', 'Season FD_Fantasy', 'L10 FD_Fantasy', 'L5 FD_Fantasy', 'L3 FD_Fantasy', 'Trend FD_Median']]
|
| 45 |
|
| 46 |
+
dk_fppm_table = trend_table[['PLAYER_NAME', 'Team', 'Position', 'Season FPPM', 'L10 FPPM', 'L5 FPPM', 'L3 FPPM', 'Trend FPPM']]
|
| 47 |
|
| 48 |
+
fd_fppm_table = trend_table[['PLAYER_NAME', 'Team', 'FD_Position', 'Season FPPM', 'L10 FPPM', 'L5 FPPM', 'L3 FPPM', 'Trend FPPM']]
|
| 49 |
|
| 50 |
dk_proj_medians_table = trend_table[['PLAYER_NAME', 'Team', 'Position', 'DK_Salary', 'DK_Proj', 'Adj Median', 'DK_Avg_Val', 'Adj Ceiling', 'DK_Ceiling_Value']]
|
| 51 |
|
|
|
|
| 84 |
trend_table = trend_table.set_axis(['PLAYER_NAME', 'Team', 'Position', 'Season MIN', 'L10 MIN', 'L5 MIN', 'L3 MIN', 'Trend Min', 'Season Fantasy', 'L10 Fantasy', 'L5 Fantasy', 'L3 Fantasy',
|
| 85 |
'Trend Median', 'Season FPPM', 'L10 FPPM', 'L5 FPPM', 'L3 FPPM', 'Trend FPPM', 'DK_Proj', 'Adj Median', 'Adj Ceiling',
|
| 86 |
'Salary', 'Avg_Val', 'Ceiling_Value'], axis=1)
|
| 87 |
+
minutes_table = minutes_table.set_axis(['PLAYER_NAME', 'Team', 'Position', 'Season MIN', 'L10 MIN', 'L5 MIN', 'L3 MIN', 'Trend Min'], axis=1)
|
| 88 |
+
medians_table = medians_table.set_axis(['PLAYER_NAME', 'Team', 'Position', 'Season Fantasy', 'L10 Fantasy', 'L5 Fantasy', 'L3 Fantasy', 'Trend Median'], axis=1)
|
| 89 |
+
fppm_table = fppm_table.set_axis(['PLAYER_NAME', 'Team', 'Position', 'Season FPPM', 'L10 FPPM', 'L5 FPPM', 'L3 FPPM', 'Trend FPPM'], axis=1)
|
| 90 |
proj_medians_table = proj_medians_table.set_axis(['PLAYER_NAME', 'Team', 'Position', 'Salary', 'Proj',
|
| 91 |
'Adj Median', 'Avg_Val', 'Adj Ceiling', 'Ceiling_Value'], axis=1)
|
| 92 |
if split_var1 == 'Overall':
|
|
|
|
| 115 |
elif split_var2 == 'All':
|
| 116 |
team_var1 = view_var1
|
| 117 |
|
| 118 |
+
split_var2 = st.radio("Would you like to view all positions or specific ones?", ('All', 'Specific Positions'), key='split_var2')
|
| 119 |
+
if split_var2 == 'Specific Positions':
|
| 120 |
+
pos_var1 = st.multiselect('Which positions would you like to include in the tables?', options = ['PG', 'SG', 'SF', 'PF', 'C'], key='pos_var1')
|
| 121 |
+
elif split_var2 == 'All':
|
| 122 |
+
pos_var1 = ['PG', 'SG', 'SF', 'PF', 'C']
|
| 123 |
+
|
| 124 |
elif split_var1 == 'Fantasy Trends':
|
| 125 |
view_var1 = trend_table.Team.values.tolist()
|
| 126 |
split_var2 = st.radio("Would you like to view all teams or specific ones?", ('All', 'Specific Teams'), key='split_var2')
|
|
|
|
| 129 |
team_var1 = st.multiselect('Which teams would you like to include in the tables?', options = view_var1, key='team_var1')
|
| 130 |
elif split_var2 == 'All':
|
| 131 |
team_var1 = view_var1
|
| 132 |
+
|
| 133 |
+
split_var2 = st.radio("Would you like to view all positions or specific ones?", ('All', 'Specific Positions'), key='split_var2')
|
| 134 |
+
if split_var2 == 'Specific Positions':
|
| 135 |
+
pos_var1 = st.multiselect('Which positions would you like to include in the tables?', options = ['PG', 'SG', 'SF', 'PF', 'C'], key='pos_var1')
|
| 136 |
+
elif split_var2 == 'All':
|
| 137 |
+
pos_var1 = ['PG', 'SG', 'SF', 'PF', 'C']
|
| 138 |
|
| 139 |
elif split_var1 == 'FPPM Trends':
|
| 140 |
view_var1 = trend_table.Team.values.tolist()
|
|
|
|
| 144 |
team_var1 = st.multiselect('Which teams would you like to include in the tables?', options = view_var1, key='team_var1')
|
| 145 |
elif split_var2 == 'All':
|
| 146 |
team_var1 = view_var1
|
| 147 |
+
|
| 148 |
+
split_var2 = st.radio("Would you like to view all positions or specific ones?", ('All', 'Specific Positions'), key='split_var2')
|
| 149 |
+
if split_var2 == 'Specific Positions':
|
| 150 |
+
pos_var1 = st.multiselect('Which positions would you like to include in the tables?', options = ['PG', 'SG', 'SF', 'PF', 'C'], key='pos_var1')
|
| 151 |
+
elif split_var2 == 'All':
|
| 152 |
+
pos_var1 = ['PG', 'SG', 'SF', 'PF', 'C']
|
| 153 |
|
| 154 |
elif split_var1 == 'Slate specific':
|
| 155 |
view_var1 = trend_table.Team.values.tolist()
|
|
|
|
| 160 |
elif split_var2 == 'All':
|
| 161 |
team_var1 = view_var1
|
| 162 |
|
| 163 |
+
split_var2 = st.radio("Would you like to view all positions or specific ones?", ('All', 'Specific Positions'), key='split_var2')
|
| 164 |
+
if split_var2 == 'Specific Positions':
|
| 165 |
pos_var1 = st.multiselect('Which positions would you like to include in the tables?', options = ['PG', 'SG', 'SF', 'PF', 'C'], key='pos_var1')
|
| 166 |
+
elif split_var2 == 'All':
|
| 167 |
pos_var1 = ['PG', 'SG', 'SF', 'PF', 'C']
|
| 168 |
|
| 169 |
proj_var1 = st.slider("Is there a certain projection range you want to view?", 0, 100, (10, 100), key='proj_var1')
|
|
|
|
| 186 |
|
| 187 |
elif split_var1 == 'Minutes Trends':
|
| 188 |
table_display = minutes_table[minutes_table['Team'].isin(team_var1)]
|
| 189 |
+
table_display = table_display[table_display['Position'].str.contains('|'.join(pos_var1))]
|
| 190 |
table_display = table_display.set_index('PLAYER_NAME')
|
| 191 |
st.dataframe(table_display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
| 192 |
st.download_button(
|
|
|
|
| 198 |
|
| 199 |
elif split_var1 == 'Fantasy Trends':
|
| 200 |
table_display = medians_table[medians_table['Team'].isin(team_var1)]
|
| 201 |
+
table_display = table_display[table_display['Position'].str.contains('|'.join(pos_var1))]
|
| 202 |
table_display = table_display.set_index('PLAYER_NAME')
|
| 203 |
st.dataframe(table_display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
| 204 |
st.download_button(
|
|
|
|
| 210 |
|
| 211 |
elif split_var1 == 'FPPM Trends':
|
| 212 |
table_display = fppm_table[fppm_table['Team'].isin(team_var1)]
|
| 213 |
+
table_display = table_display[table_display['Position'].str.contains('|'.join(pos_var1))]
|
| 214 |
table_display = table_display.set_index('PLAYER_NAME')
|
| 215 |
st.dataframe(table_display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
|
| 216 |
st.download_button(
|