Multichem commited on
Commit
25d03a1
·
1 Parent(s): 7923b21

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +54 -1
app.py CHANGED
@@ -63,7 +63,7 @@ def convert_df_to_csv(df):
63
 
64
  dk_raw, fd_raw = load_overall_stats()
65
 
66
- tab1, tab2 = st.tabs(['Uploads and Info', 'Range of Outcomes'])
67
 
68
  with tab1:
69
  st.info("The Projections file can have any columns in any order, but must contain columns explicitly named: 'Player', 'Salary', 'Position', 'Team', 'Opp', 'Minutes', 'Median', 'Own'.")
@@ -91,6 +91,59 @@ with tab2:
91
  dk_raw, fd_raw = load_overall_stats()
92
  for key in st.session_state.keys():
93
  del st.session_state[key]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
94
  slate_var1 = st.radio("Which data are you loading?", ('Paydirt', 'User'), key='slate_var1')
95
  site_var1 = st.radio("What table would you like to display?", ('Draftkings', 'Fanduel'), key='site_var1')
96
  if site_var1 == 'Draftkings':
 
63
 
64
  dk_raw, fd_raw = load_overall_stats()
65
 
66
+ tab1, tab2, tab3 = st.tabs(['Uploads and Info', 'Range of Outcomes', 'Custom Range of Outcomes'])
67
 
68
  with tab1:
69
  st.info("The Projections file can have any columns in any order, but must contain columns explicitly named: 'Player', 'Salary', 'Position', 'Team', 'Opp', 'Minutes', 'Median', 'Own'.")
 
91
  dk_raw, fd_raw = load_overall_stats()
92
  for key in st.session_state.keys():
93
  del st.session_state[key]
94
+ site_var2 = st.radio("What table would you like to display?", ('Draftkings', 'Fanduel'), key='site_var2')
95
+ if site_var2 == 'Draftkings':
96
+ raw_baselines = dk_raw
97
+ elif site_var2 == 'Fanduel':
98
+ raw_baselines = fd_raw
99
+ split_var2 = st.radio("Are you running the full slate or crtain games?", ('Full Slate Run', 'Specific Games'), key='split_var2')
100
+ if split_var2 == 'Specific Games':
101
+ team_var2 = st.multiselect('Which teams would you like to include in the ROO?', options = raw_baselines['Team'].unique(), key='team_var2')
102
+ elif split_var2 == 'Full Slate Run':
103
+ team_var2 = raw_baselines.Team.values.tolist()
104
+ pos_var2 = st.selectbox('View specific position?', options = ['All', 'PG', 'SG', 'SF', 'PF', 'C'])
105
+
106
+ with col2:
107
+ display_container = st.empty()
108
+ display_dl_container = st.empty()
109
+ hold_container = st.empty()
110
+ if st.button('Create Range of Outcomes for Slate'):
111
+ with hold_container:
112
+ display_proj = raw_baselines[raw_baselines['Team'].isin(team_var2)]
113
+
114
+ st.session_state.display_proj = display_proj
115
+
116
+ hold_container = st.empty()
117
+
118
+ with display_container:
119
+ display_container = st.empty()
120
+ if 'display_proj' in st.session_state:
121
+ if pos_var2 == 'All':
122
+ st.session_state.display_proj = st.session_state.display_proj
123
+ elif pos_var2 != 'All':
124
+ st.session_state.display_proj = st.session_state.display_proj[st.session_state.display_proj['Position'].str.contains(pos_var2)]
125
+ st.dataframe(st.session_state.display_proj.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
126
+
127
+ with display_dl_container:
128
+ display_dl_container = st.empty()
129
+ if 'display_proj' in st.session_state:
130
+ st.download_button(
131
+ label="Export Tables",
132
+ data=convert_df_to_csv(st.session_state.display_proj),
133
+ file_name='NBA_ROO_export.csv',
134
+ mime='text/csv',
135
+ )
136
+
137
+ with tab3:
138
+
139
+ col1, col2 = st.columns([1, 9])
140
+
141
+ with col1:
142
+ if st.button("Load/Reset Data", key='reset2'):
143
+ st.cache_data.clear()
144
+ dk_raw, fd_raw = load_overall_stats()
145
+ for key in st.session_state.keys():
146
+ del st.session_state[key]
147
  slate_var1 = st.radio("Which data are you loading?", ('Paydirt', 'User'), key='slate_var1')
148
  site_var1 = st.radio("What table would you like to display?", ('Draftkings', 'Fanduel'), key='site_var1')
149
  if site_var1 == 'Draftkings':