Spaces:
Running
Running
James McCool
commited on
Commit
·
ac9b445
1
Parent(s):
9990caa
Refactor tab1 layout and improve user interface for ROO projection view
Browse files
app.py
CHANGED
@@ -281,84 +281,105 @@ with st.sidebar:
|
|
281 |
st.write(f'Total LevX: {levx_sum:.2f}')
|
282 |
|
283 |
with tab1:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
284 |
|
285 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
286 |
|
287 |
-
|
288 |
-
st.info(t_stamp)
|
289 |
-
if st.button("Load/Reset Data", key='reset1'):
|
290 |
-
st.cache_data.clear()
|
291 |
-
dk_raw, fd_raw, dk_raw_sec, fd_raw_sec, roo_raw, timestamp, roo_backlog = load_overall_stats()
|
292 |
-
id_dict = dict(zip(roo_raw.Player, roo_raw.player_ID))
|
293 |
-
dk_lineups = init_DK_lineups()
|
294 |
-
fd_lineups = init_FD_lineups()
|
295 |
-
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
296 |
-
for key in st.session_state.keys():
|
297 |
-
del st.session_state[key]
|
298 |
-
view_var2 = st.radio("What view would you like to display?", ('Simple', 'Advanced'), key='view_var2')
|
299 |
-
st.info("Advanced view includes all stats and thresholds, simple includes just basic columns for ease of use on mobile")
|
300 |
-
site_var2 = st.radio("What table would you like to display?", ('Draftkings', 'Fanduel'), key='site_var2')
|
301 |
if site_var2 == 'Draftkings':
|
302 |
site_baselines = roo_raw[roo_raw['site'] == 'Draftkings']
|
303 |
site_backlog = roo_backlog[roo_backlog['site'] == 'Draftkings']
|
304 |
elif site_var2 == 'Fanduel':
|
305 |
site_baselines = roo_raw[roo_raw['site'] == 'Fanduel']
|
306 |
site_backlog = roo_backlog[roo_backlog['site'] == 'Fanduel']
|
307 |
-
|
|
|
308 |
if slate_split == 'Main Slate':
|
309 |
raw_baselines = site_baselines[site_baselines['slate'] == 'Main Slate']
|
310 |
elif slate_split == 'Secondary':
|
311 |
raw_baselines = site_baselines[site_baselines['slate'] == 'Secondary Slate']
|
312 |
elif slate_split == 'Backlog':
|
313 |
raw_baselines = site_backlog
|
314 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
315 |
if view_all:
|
316 |
-
raw_baselines = raw_baselines
|
317 |
raw_baselines = raw_baselines.sort_values(by=['Median', 'Date'], ascending=[False, False])
|
318 |
else:
|
319 |
-
date_var2 = st.date_input("Which date would you like to view?", key='date_var2')
|
320 |
raw_baselines = raw_baselines[raw_baselines['Date'] == date_var2.strftime('%m-%d-%Y')]
|
321 |
raw_baselines = raw_baselines.sort_values(by='Median', ascending=False)
|
322 |
-
split_var2 = st.radio("Are you running the full slate or certain games?", ('Full Slate Run', 'Specific Games'), key='split_var2')
|
323 |
-
if split_var2 == 'Specific Games':
|
324 |
-
team_var2 = st.multiselect('Which teams would you like to include in the ROO?', options = raw_baselines['Team'].unique(), key='team_var2')
|
325 |
-
elif split_var2 == 'Full Slate Run':
|
326 |
-
team_var2 = raw_baselines.Team.values.tolist()
|
327 |
-
pos_var2 = st.selectbox('View specific position?', options = ['All', 'PG', 'SG', 'SF', 'PF', 'C'], key='pos_var2')
|
328 |
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
|
|
352 |
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
362 |
|
363 |
with tab2:
|
364 |
col1, col2 = st.columns([1, 7])
|
|
|
281 |
st.write(f'Total LevX: {levx_sum:.2f}')
|
282 |
|
283 |
with tab1:
|
284 |
+
with st.container():
|
285 |
+
st.info("Advanced view includes all stats and thresholds, simple includes just basic columns for ease of use on mobile")
|
286 |
+
with st.container():
|
287 |
+
# First row - timestamp and reset button
|
288 |
+
col1, col2 = st.columns([3, 1])
|
289 |
+
with col1:
|
290 |
+
st.info(t_stamp)
|
291 |
+
with col2:
|
292 |
+
if st.button("Load/Reset Data", key='reset1'):
|
293 |
+
st.cache_data.clear()
|
294 |
+
dk_raw, fd_raw, dk_raw_sec, fd_raw_sec, roo_raw, timestamp, roo_backlog = load_overall_stats()
|
295 |
+
id_dict = dict(zip(roo_raw.Player, roo_raw.player_ID))
|
296 |
+
dk_lineups = init_DK_lineups()
|
297 |
+
fd_lineups = init_FD_lineups()
|
298 |
+
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
299 |
+
for key in st.session_state.keys():
|
300 |
+
del st.session_state[key]
|
301 |
|
302 |
+
# Second row - main options
|
303 |
+
col1, col2, col3 = st.columns(3)
|
304 |
+
with col1:
|
305 |
+
view_var2 = st.radio("View Type", ('Simple', 'Advanced'), key='view_var2')
|
306 |
+
with col2:
|
307 |
+
site_var2 = st.radio("Site", ('Draftkings', 'Fanduel'), key='site_var2')
|
308 |
+
with col3:
|
309 |
+
slate_split = st.radio("Slate Type", ('Main Slate', 'Secondary', 'Backlog'), key='slate_split')
|
310 |
|
311 |
+
# Process site selection
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
312 |
if site_var2 == 'Draftkings':
|
313 |
site_baselines = roo_raw[roo_raw['site'] == 'Draftkings']
|
314 |
site_backlog = roo_backlog[roo_backlog['site'] == 'Draftkings']
|
315 |
elif site_var2 == 'Fanduel':
|
316 |
site_baselines = roo_raw[roo_raw['site'] == 'Fanduel']
|
317 |
site_backlog = roo_backlog[roo_backlog['site'] == 'Fanduel']
|
318 |
+
|
319 |
+
# Process slate selection
|
320 |
if slate_split == 'Main Slate':
|
321 |
raw_baselines = site_baselines[site_baselines['slate'] == 'Main Slate']
|
322 |
elif slate_split == 'Secondary':
|
323 |
raw_baselines = site_baselines[site_baselines['slate'] == 'Secondary Slate']
|
324 |
elif slate_split == 'Backlog':
|
325 |
raw_baselines = site_backlog
|
326 |
+
# Third row - backlog options
|
327 |
+
col1, col2 = st.columns(2)
|
328 |
+
with col1:
|
329 |
+
view_all = st.checkbox("View all dates?", key='view_all')
|
330 |
+
with col2:
|
331 |
+
if not view_all:
|
332 |
+
date_var2 = st.date_input("Select date", key='date_var2')
|
333 |
+
|
334 |
if view_all:
|
|
|
335 |
raw_baselines = raw_baselines.sort_values(by=['Median', 'Date'], ascending=[False, False])
|
336 |
else:
|
|
|
337 |
raw_baselines = raw_baselines[raw_baselines['Date'] == date_var2.strftime('%m-%d-%Y')]
|
338 |
raw_baselines = raw_baselines.sort_values(by='Median', ascending=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
339 |
|
340 |
+
# Fourth row - final options
|
341 |
+
col1, col2 = st.columns(2)
|
342 |
+
with col1:
|
343 |
+
split_var2 = st.radio("Slate Range", ('Full Slate Run', 'Specific Games'), key='split_var2')
|
344 |
+
if split_var2 == 'Specific Games':
|
345 |
+
team_var2 = st.multiselect('Select teams for ROO', options=raw_baselines['Team'].unique(), key='team_var2')
|
346 |
+
else:
|
347 |
+
team_var2 = raw_baselines.Team.values.tolist()
|
348 |
+
with col2:
|
349 |
+
pos_var2 = st.selectbox('Position Filter', options=['All', 'PG', 'SG', 'SF', 'PF', 'C'], key='pos_var2')
|
350 |
+
|
351 |
+
display_container_1 = st.empty()
|
352 |
+
display_dl_container_1 = st.empty()
|
353 |
+
display_proj = raw_baselines[raw_baselines['Team'].isin(team_var2)]
|
354 |
+
if view_var2 == 'Advanced':
|
355 |
+
display_proj = display_proj[['Player', 'Minutes Proj', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '4x%', '5x%', '6x%', 'GPP%',
|
356 |
+
'Own', 'Small_Own', 'Large_Own', 'Cash_Own', 'CPT_Own', 'LevX', 'ValX']]
|
357 |
+
elif view_var2 == 'Simple':
|
358 |
+
display_proj = display_proj[['Player', 'Team', 'Position', 'Median', 'GPP%', 'Own']]
|
359 |
+
export_data = display_proj.copy()
|
360 |
+
|
361 |
+
|
362 |
+
display_proj = display_proj.set_index('Player')
|
363 |
+
st.session_state.display_proj = display_proj
|
364 |
|
365 |
+
with display_container_1:
|
366 |
+
display_container = st.empty()
|
367 |
+
if 'display_proj' in st.session_state:
|
368 |
+
if pos_var2 == 'All':
|
369 |
+
st.session_state.display_proj = st.session_state.display_proj
|
370 |
+
elif pos_var2 != 'All':
|
371 |
+
st.session_state.display_proj = st.session_state.display_proj[st.session_state.display_proj['Position'].str.contains(pos_var2)]
|
372 |
+
st.dataframe(st.session_state.display_proj.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(roo_format, precision=2), height=1000, use_container_width = True)
|
373 |
+
|
374 |
+
with display_dl_container_1:
|
375 |
+
display_dl_container = st.empty()
|
376 |
+
if 'display_proj' in st.session_state:
|
377 |
+
st.download_button(
|
378 |
+
label="Export Tables",
|
379 |
+
data=convert_df_to_csv(export_data),
|
380 |
+
file_name='NBA_ROO_export.csv',
|
381 |
+
mime='text/csv',
|
382 |
+
)
|
383 |
|
384 |
with tab2:
|
385 |
col1, col2 = st.columns([1, 7])
|