James McCool
commited on
Commit
·
fccc635
1
Parent(s):
4789d7b
added a whole bunch of important objects
Browse files
app.py
CHANGED
@@ -68,8 +68,6 @@ def init_load():
|
|
68 |
load_display.rename(columns={"Name": "Player", "Fantasy": "Median", "Minutes Proj": "Minutes"}, inplace = True)
|
69 |
|
70 |
timestamp = load_display['timestamp'].values[0]
|
71 |
-
|
72 |
-
load_display = load_display[['Player', 'Salary', 'Position', 'Team', 'Opp', 'Minutes', 'Median', 'Own']]
|
73 |
roo_raw = load_display.loc[load_display['Median'] > 0]
|
74 |
|
75 |
worksheet = sh.worksheet('DK_SD_Build')
|
@@ -100,8 +98,6 @@ def init_load():
|
|
100 |
load_display = load_display[['Player', 'Salary', 'Position', 'Team', 'Opp', 'Median', 'Own', 'Minutes']]
|
101 |
fd_roo_raw_2 = load_display.loc[load_display['Median'] > 0]
|
102 |
|
103 |
-
|
104 |
-
|
105 |
return roo_raw, dk_roo_raw, dk_roo_raw_2, fd_roo_raw, fd_roo_raw_2, timestamp
|
106 |
|
107 |
roo_raw, dk_roo_raw, dk_roo_raw_2, fd_roo_raw, fd_roo_raw_2, t_stamp = init_load()
|
@@ -110,56 +106,61 @@ roo_raw, dk_roo_raw, dk_roo_raw_2, fd_roo_raw, fd_roo_raw_2, t_stamp = init_load
|
|
110 |
def convert_df_to_csv(df):
|
111 |
return df.to_csv().encode('utf-8')
|
112 |
|
113 |
-
|
114 |
-
|
115 |
-
with
|
116 |
-
st.
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
|
|
147 |
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
st.session_state.display_proj = st.session_state.display_proj
|
153 |
-
elif pos_var2 != 'All':
|
154 |
-
st.session_state.display_proj = st.session_state.display_proj[st.session_state.display_proj['Position'].str.contains(pos_var2)]
|
155 |
-
st.dataframe(st.session_state.display_proj.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), height=1000, use_container_width = True)
|
156 |
-
|
157 |
-
with display_dl_container_1:
|
158 |
-
display_dl_container = st.empty()
|
159 |
if 'display_proj' in st.session_state:
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
68 |
load_display.rename(columns={"Name": "Player", "Fantasy": "Median", "Minutes Proj": "Minutes"}, inplace = True)
|
69 |
|
70 |
timestamp = load_display['timestamp'].values[0]
|
|
|
|
|
71 |
roo_raw = load_display.loc[load_display['Median'] > 0]
|
72 |
|
73 |
worksheet = sh.worksheet('DK_SD_Build')
|
|
|
98 |
load_display = load_display[['Player', 'Salary', 'Position', 'Team', 'Opp', 'Median', 'Own', 'Minutes']]
|
99 |
fd_roo_raw_2 = load_display.loc[load_display['Median'] > 0]
|
100 |
|
|
|
|
|
101 |
return roo_raw, dk_roo_raw, dk_roo_raw_2, fd_roo_raw, fd_roo_raw_2, timestamp
|
102 |
|
103 |
roo_raw, dk_roo_raw, dk_roo_raw_2, fd_roo_raw, fd_roo_raw_2, t_stamp = init_load()
|
|
|
106 |
def convert_df_to_csv(df):
|
107 |
return df.to_csv().encode('utf-8')
|
108 |
|
109 |
+
tab1, tab2 = st.tabs(['Range of Outcomes', 'Uploads and Info'])
|
110 |
+
|
111 |
+
with tab1:
|
112 |
+
col1, col2 = st.columns([1, 9])
|
113 |
+
|
114 |
+
with col1:
|
115 |
+
st.info(t_stamp)
|
116 |
+
if st.button("Load/Reset Data", key='reset1'):
|
117 |
+
st.cache_data.clear()
|
118 |
+
dk_raw, fd_raw, dk_raw_sec, fd_raw_sec, roo_raw, timestamp = init_load()
|
119 |
+
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
120 |
+
for key in st.session_state.keys():
|
121 |
+
del st.session_state[key]
|
122 |
+
site_var2 = st.radio("What table would you like to display?", ('Draftkings', 'Fanduel'), key='site_var2')
|
123 |
+
if site_var2 == 'Draftkings':
|
124 |
+
site_baselines = roo_raw[roo_raw['site'] == 'Draftkings']
|
125 |
+
elif site_var2 == 'Fanduel':
|
126 |
+
site_baselines = roo_raw[roo_raw['site'] == 'Fanduel']
|
127 |
+
slate_split = st.radio("Are you viewing the main slate or the secondary slate?", ('Showdown #1', 'Showdown #2'), key='slate_split')
|
128 |
+
if slate_split == 'Showdown #1':
|
129 |
+
raw_baselines = site_baselines[site_baselines['slate'] == 'Showdown #1']
|
130 |
+
elif slate_split == 'Showdown #2':
|
131 |
+
raw_baselines = site_baselines[site_baselines['slate'] == 'Showdown #2']
|
132 |
+
split_var2 = st.radio("Are you running the full slate or certain games?", ('Full Slate Run', 'Specific Games'), key='split_var2')
|
133 |
+
if split_var2 == 'Specific Games':
|
134 |
+
team_var2 = st.multiselect('Which teams would you like to include in the ROO?', options = raw_baselines['Team'].unique(), key='team_var2')
|
135 |
+
elif split_var2 == 'Full Slate Run':
|
136 |
+
team_var2 = raw_baselines.Team.values.tolist()
|
137 |
+
pos_var2 = st.selectbox('View specific position?', options = ['All', 'PG', 'SG', 'SF', 'PF', 'C'], key='pos_var2')
|
138 |
+
|
139 |
+
with col2:
|
140 |
+
display_container_1 = st.empty()
|
141 |
+
display_dl_container_1 = st.empty()
|
142 |
+
display_proj = raw_baselines[raw_baselines['Team'].isin(team_var2)]
|
143 |
+
display_proj = display_proj.drop(columns=['site', 'version', 'slate', 'timestamp'])
|
144 |
|
145 |
+
st.session_state.display_proj = display_proj
|
146 |
+
|
147 |
+
with display_container_1:
|
148 |
+
display_container = st.empty()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
if 'display_proj' in st.session_state:
|
150 |
+
if pos_var2 == 'All':
|
151 |
+
st.session_state.display_proj = st.session_state.display_proj
|
152 |
+
elif pos_var2 != 'All':
|
153 |
+
st.session_state.display_proj = st.session_state.display_proj[st.session_state.display_proj['Position'].str.contains(pos_var2)]
|
154 |
+
st.dataframe(st.session_state.display_proj.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), height=1000, use_container_width = True)
|
155 |
+
|
156 |
+
with display_dl_container_1:
|
157 |
+
display_dl_container = st.empty()
|
158 |
+
if 'display_proj' in st.session_state:
|
159 |
+
st.download_button(
|
160 |
+
label="Export Tables",
|
161 |
+
data=convert_df_to_csv(st.session_state.display_proj),
|
162 |
+
file_name='NBA_SD_ROO_export.csv',
|
163 |
+
mime='text/csv',
|
164 |
+
)
|
165 |
+
with tab2:
|
166 |
+
st.write("Yeah man idk that's crazy")
|