Spaces:
Running
Running
James McCool
commited on
Commit
·
5236120
1
Parent(s):
78ac3ba
Add view type selector for improved mobile and desktop user experience
Browse filesIntroduced a new "View Type" radio button for each tab (Players, Line Combos, Power Play) to toggle between "Simple" and "Advanced" views. The Simple view provides essential columns for mobile users, while the Advanced view offers comprehensive statistics. Also added an informative info message explaining the view type functionality.
app.py
CHANGED
@@ -90,11 +90,14 @@ tab1, tab2, tab3 = st.tabs(["Player Range of Outcomes", "Line Combo Range of Out
|
|
90 |
|
91 |
with tab1:
|
92 |
with st.expander("Info and Filters"):
|
|
|
|
|
93 |
st.info(t_stamp)
|
94 |
if st.button("Load/Reset Data", key='reset1'):
|
95 |
st.cache_data.clear()
|
96 |
player_frame, line_frame, pp_frame, timestamp = player_stat_table()
|
97 |
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
|
|
98 |
site_var1 = st.radio("What table would you like to display?", ('Draftkings', 'Fanduel'), key='site_var1')
|
99 |
main_var1 = st.radio("Main slate or secondary slate?", ('Main Slate', 'Secondary Slate'), key='main_var1')
|
100 |
split_var1 = st.radio("Would you like to view the whole slate or just specific games?", ('Full Slate Run', 'Specific Games'), key='split_var1')
|
@@ -120,21 +123,30 @@ with tab1:
|
|
120 |
final_Proj = final_Proj.sort_values(by='Median', ascending=False)
|
121 |
if pos_var1 == 'All':
|
122 |
final_Proj = final_Proj.sort_values(by='Median', ascending=False)
|
123 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
124 |
st.download_button(
|
125 |
label="Export Tables",
|
126 |
-
data=convert_df_to_csv(
|
127 |
file_name='NHL_player_export.csv',
|
128 |
mime='text/csv',
|
129 |
)
|
130 |
|
131 |
with tab2:
|
132 |
with st.expander("Info and Filters"):
|
|
|
|
|
133 |
st.info(t_stamp)
|
134 |
if st.button("Load/Reset Data", key='reset2'):
|
135 |
st.cache_data.clear()
|
136 |
player_frame, line_frame, pp_frame, timestamp = player_stat_table()
|
137 |
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
|
|
138 |
site_var2 = st.radio("What table would you like to display?", ('Draftkings', 'Fanduel'), key='site_var2')
|
139 |
main_var2 = st.radio("Main slate or secondary slate?", ('Main Slate', 'Secondary Slate'), key='main_var2')
|
140 |
sal_var2 = st.slider("Is there a certain price range you want to view?", 5000, 40000, (5000, 40000), key='sal_var2')
|
@@ -146,21 +158,30 @@ with tab2:
|
|
146 |
final_line_combos = final_line_combos[final_line_combos['Salary'] <= sal_var2[1]]
|
147 |
final_line_combos = final_line_combos.drop_duplicates(subset=['Player'])
|
148 |
final_line_combos = final_line_combos.sort_values(by='Median', ascending=False)
|
149 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
st.download_button(
|
151 |
label="Export Tables",
|
152 |
-
data=convert_df_to_csv(
|
153 |
file_name='NHL_linecombos_export.csv',
|
154 |
mime='text/csv',
|
155 |
)
|
156 |
|
157 |
with tab3:
|
158 |
with st.expander("Info and Filters"):
|
|
|
|
|
159 |
st.info(t_stamp)
|
160 |
if st.button("Load/Reset Data", key='reset3'):
|
161 |
st.cache_data.clear()
|
162 |
player_frame, line_frame, pp_frame, timestamp = player_stat_table()
|
163 |
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
|
|
164 |
site_var3 = st.radio("What table would you like to display?", ('Draftkings', 'Fanduel'), key='site_var3')
|
165 |
main_var3 = st.radio("Main slate or secondary slate?", ('Main Slate', 'Secondary Slate'), key='main_var3')
|
166 |
sal_var3 = st.slider("Is there a certain price range you want to view?", 5000, 40000, (5000, 40000), key='sal_var3')
|
@@ -172,10 +193,16 @@ with tab3:
|
|
172 |
final_pp_combos = final_pp_combos[final_pp_combos['Salary'] <= sal_var3[1]]
|
173 |
final_pp_combos = final_pp_combos.drop_duplicates(subset=['Player'])
|
174 |
final_pp_combos = final_pp_combos.sort_values(by='Median', ascending=False)
|
175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
176 |
st.download_button(
|
177 |
label="Export Tables",
|
178 |
-
data=convert_df_to_csv(
|
179 |
file_name='NHL_powerplay_export.csv',
|
180 |
mime='text/csv',
|
181 |
)
|
|
|
90 |
|
91 |
with tab1:
|
92 |
with st.expander("Info and Filters"):
|
93 |
+
with st.container():
|
94 |
+
st.info("Advanced view includes all stats and thresholds, simple includes just basic columns for ease of use on mobile")
|
95 |
st.info(t_stamp)
|
96 |
if st.button("Load/Reset Data", key='reset1'):
|
97 |
st.cache_data.clear()
|
98 |
player_frame, line_frame, pp_frame, timestamp = player_stat_table()
|
99 |
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
100 |
+
view_var1 = st.radio("View Type", ("Simple", "Advanced"), key='view_var1')
|
101 |
site_var1 = st.radio("What table would you like to display?", ('Draftkings', 'Fanduel'), key='site_var1')
|
102 |
main_var1 = st.radio("Main slate or secondary slate?", ('Main Slate', 'Secondary Slate'), key='main_var1')
|
103 |
split_var1 = st.radio("Would you like to view the whole slate or just specific games?", ('Full Slate Run', 'Specific Games'), key='split_var1')
|
|
|
123 |
final_Proj = final_Proj.sort_values(by='Median', ascending=False)
|
124 |
if pos_var1 == 'All':
|
125 |
final_Proj = final_Proj.sort_values(by='Median', ascending=False)
|
126 |
+
|
127 |
+
if view_var1 == 'Advanced':
|
128 |
+
display_proj = final_Proj[['Player', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%',
|
129 |
+
'Own', 'Small Field Own%', 'Large Field Own%', 'Cash Own%', 'CPT_Own']]
|
130 |
+
elif view_var1 == 'Simple':
|
131 |
+
display_proj = final_Proj[['Player', 'Position', 'Salary', 'Median', '3x%', 'Own']]
|
132 |
+
st.dataframe(display_proj.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(player_roo_format, precision=2), use_container_width = True, hide_index=True)
|
133 |
st.download_button(
|
134 |
label="Export Tables",
|
135 |
+
data=convert_df_to_csv(display_proj),
|
136 |
file_name='NHL_player_export.csv',
|
137 |
mime='text/csv',
|
138 |
)
|
139 |
|
140 |
with tab2:
|
141 |
with st.expander("Info and Filters"):
|
142 |
+
with st.container():
|
143 |
+
st.info("Advanced view includes all stats and thresholds, simple includes just basic columns for ease of use on mobile")
|
144 |
st.info(t_stamp)
|
145 |
if st.button("Load/Reset Data", key='reset2'):
|
146 |
st.cache_data.clear()
|
147 |
player_frame, line_frame, pp_frame, timestamp = player_stat_table()
|
148 |
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
149 |
+
view_var2 = st.radio("View Type", ("Simple", "Advanced"), key='view_var2')
|
150 |
site_var2 = st.radio("What table would you like to display?", ('Draftkings', 'Fanduel'), key='site_var2')
|
151 |
main_var2 = st.radio("Main slate or secondary slate?", ('Main Slate', 'Secondary Slate'), key='main_var2')
|
152 |
sal_var2 = st.slider("Is there a certain price range you want to view?", 5000, 40000, (5000, 40000), key='sal_var2')
|
|
|
158 |
final_line_combos = final_line_combos[final_line_combos['Salary'] <= sal_var2[1]]
|
159 |
final_line_combos = final_line_combos.drop_duplicates(subset=['Player'])
|
160 |
final_line_combos = final_line_combos.sort_values(by='Median', ascending=False)
|
161 |
+
|
162 |
+
if view_var2 == 'Advanced':
|
163 |
+
display_proj_lines = final_line_combos[['Player', 'SK1', 'SK2', 'SK3', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '50+%', '2x%', '3x%', '4x%',
|
164 |
+
'Own']]
|
165 |
+
elif view_var2 == 'Simple':
|
166 |
+
display_proj_lines = final_line_combos[['SK1', 'SK2', 'SK3', 'Salary', 'Median', '3x%', 'Own']]
|
167 |
+
st.dataframe(display_proj_lines.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(player_roo_format, precision=2), use_container_width = True, hide_index=True)
|
168 |
st.download_button(
|
169 |
label="Export Tables",
|
170 |
+
data=convert_df_to_csv(display_proj_lines),
|
171 |
file_name='NHL_linecombos_export.csv',
|
172 |
mime='text/csv',
|
173 |
)
|
174 |
|
175 |
with tab3:
|
176 |
with st.expander("Info and Filters"):
|
177 |
+
with st.container():
|
178 |
+
st.info("Advanced view includes all stats and thresholds, simple includes just basic columns for ease of use on mobile")
|
179 |
st.info(t_stamp)
|
180 |
if st.button("Load/Reset Data", key='reset3'):
|
181 |
st.cache_data.clear()
|
182 |
player_frame, line_frame, pp_frame, timestamp = player_stat_table()
|
183 |
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
184 |
+
view_var3 = st.radio("View Type", ("Simple", "Advanced"), key='view_var3')
|
185 |
site_var3 = st.radio("What table would you like to display?", ('Draftkings', 'Fanduel'), key='site_var3')
|
186 |
main_var3 = st.radio("Main slate or secondary slate?", ('Main Slate', 'Secondary Slate'), key='main_var3')
|
187 |
sal_var3 = st.slider("Is there a certain price range you want to view?", 5000, 40000, (5000, 40000), key='sal_var3')
|
|
|
193 |
final_pp_combos = final_pp_combos[final_pp_combos['Salary'] <= sal_var3[1]]
|
194 |
final_pp_combos = final_pp_combos.drop_duplicates(subset=['Player'])
|
195 |
final_pp_combos = final_pp_combos.sort_values(by='Median', ascending=False)
|
196 |
+
|
197 |
+
if view_var3 == 'Advanced':
|
198 |
+
display_proj_pp = final_pp_combos[['Player', 'SK1', 'SK2', 'SK3', 'SK4', 'SK5', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '75+%', '2x%', '3x%', '4x%',
|
199 |
+
'Own']]
|
200 |
+
elif view_var3 == 'Simple':
|
201 |
+
display_proj_pp = final_pp_combos[['SK1', 'SK2', 'SK3', 'SK4', 'SK5', 'Salary', 'Median', '3x%', 'Own']]
|
202 |
+
st.dataframe(display_proj_pp.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True, hide_index=True)
|
203 |
st.download_button(
|
204 |
label="Export Tables",
|
205 |
+
data=convert_df_to_csv(display_proj_pp),
|
206 |
file_name='NHL_powerplay_export.csv',
|
207 |
mime='text/csv',
|
208 |
)
|