Update app.py
Browse files
app.py
CHANGED
@@ -38,7 +38,7 @@ def init_conn():
|
|
38 |
|
39 |
uri = st.secrets['mongo_uri']
|
40 |
client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=500000)
|
41 |
-
db = client["
|
42 |
|
43 |
NFL_Data = st.secrets['NFL_Data']
|
44 |
|
@@ -57,49 +57,68 @@ fd_columns = ['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'sal
|
|
57 |
@st.cache_data(ttl = 600)
|
58 |
def init_DK_seed_frames():
|
59 |
|
60 |
-
|
61 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
|
|
|
|
|
|
|
66 |
|
67 |
-
|
68 |
|
69 |
@st.cache_data(ttl = 599)
|
70 |
def init_FD_seed_frames():
|
71 |
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
74 |
|
75 |
-
|
76 |
-
|
77 |
-
FD_seed = raw_display.to_numpy()
|
78 |
|
79 |
-
|
|
|
|
|
|
|
|
|
80 |
|
81 |
@st.cache_data(ttl = 599)
|
82 |
def init_baselines():
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
load_display.replace('', np.nan, inplace=True)
|
99 |
-
load_display['STDev'] = load_display['Median'] / 4
|
100 |
-
load_display = load_display.drop_duplicates(subset=['Player'], keep='first')
|
101 |
-
|
102 |
-
fd_raw = load_display.dropna(subset=['Median'])
|
103 |
|
104 |
return dk_raw, fd_raw
|
105 |
|
@@ -168,10 +187,14 @@ with tab2:
|
|
168 |
FD_seed = init_FD_seed_frames()
|
169 |
dk_raw, fd_raw = init_baselines()
|
170 |
|
171 |
-
slate_var1 = st.radio("Which data are you loading?", ('Main Slate', '
|
172 |
site_var1 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'))
|
173 |
if site_var1 == 'Draftkings':
|
174 |
-
|
|
|
|
|
|
|
|
|
175 |
raw_baselines = dk_raw
|
176 |
column_names = dk_columns
|
177 |
|
@@ -188,7 +211,11 @@ with tab2:
|
|
188 |
stack_var2 = [5, 4, 3, 2, 1, 0]
|
189 |
|
190 |
elif site_var1 == 'Fanduel':
|
191 |
-
|
|
|
|
|
|
|
|
|
192 |
raw_baselines = fd_raw
|
193 |
column_names = fd_columns
|
194 |
|
@@ -252,14 +279,22 @@ with tab1:
|
|
252 |
DK_seed = init_DK_seed_frames()
|
253 |
FD_seed = init_FD_seed_frames()
|
254 |
dk_raw, fd_raw = init_baselines()
|
255 |
-
sim_slate_var1 = st.radio("Which data are you loading?", ('Main Slate', '
|
256 |
sim_site_var1 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'), key='sim_site_var1')
|
257 |
if sim_site_var1 == 'Draftkings':
|
258 |
-
|
|
|
|
|
|
|
|
|
259 |
raw_baselines = dk_raw
|
260 |
column_names = dk_columns
|
261 |
elif sim_site_var1 == 'Fanduel':
|
262 |
-
|
|
|
|
|
|
|
|
|
263 |
raw_baselines = fd_raw
|
264 |
column_names = fd_columns
|
265 |
|
|
|
38 |
|
39 |
uri = st.secrets['mongo_uri']
|
40 |
client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=500000)
|
41 |
+
db = client["NFL_Database"]
|
42 |
|
43 |
NFL_Data = st.secrets['NFL_Data']
|
44 |
|
|
|
57 |
@st.cache_data(ttl = 600)
|
58 |
def init_DK_seed_frames():
|
59 |
|
60 |
+
collection = db["DK_NFL_seed_frame"]
|
61 |
+
cursor = collection.find()
|
62 |
+
|
63 |
+
raw_display = pd.DataFrame(list(cursor))
|
64 |
+
raw_display = raw_display[['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
65 |
+
DK_seed = raw_display.to_numpy()
|
66 |
+
|
67 |
+
return DK_seed
|
68 |
+
|
69 |
+
@st.cache_data(ttl = 600)
|
70 |
+
def init_DK_Secondary_seed_frames():
|
71 |
|
72 |
+
collection = db["DK_NFL_Secondary_seed_frame"]
|
73 |
+
cursor = collection.find()
|
74 |
+
|
75 |
+
raw_display = pd.DataFrame(list(cursor))
|
76 |
+
raw_display = raw_display[['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
77 |
+
DK_seed = raw_display.to_numpy()
|
78 |
|
79 |
+
return DK_seed
|
80 |
|
81 |
@st.cache_data(ttl = 599)
|
82 |
def init_FD_seed_frames():
|
83 |
|
84 |
+
collection = db["FD_NFL_seed_frame"]
|
85 |
+
cursor = collection.find()
|
86 |
+
|
87 |
+
raw_display = pd.DataFrame(list(cursor))
|
88 |
+
raw_display = raw_display[['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
89 |
+
FD_seed = raw_display.to_numpy()
|
90 |
+
|
91 |
+
return FD_seed
|
92 |
+
|
93 |
+
@st.cache_data(ttl = 599)
|
94 |
+
def init_FD_Secondary_seed_frames():
|
95 |
|
96 |
+
collection = db["FD_NFL_Secondary_seed_frame"]
|
97 |
+
cursor = collection.find()
|
|
|
98 |
|
99 |
+
raw_display = pd.DataFrame(list(cursor))
|
100 |
+
raw_display = raw_display[['QB', 'RB1', 'RB2', 'WR1', 'WR2', 'WR3', 'TE', 'FLEX', 'DST', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
101 |
+
FD_seed = raw_display.to_numpy()
|
102 |
+
|
103 |
+
return FD_seed
|
104 |
|
105 |
@st.cache_data(ttl = 599)
|
106 |
def init_baselines():
|
107 |
+
collection = db["DK_NFL_ROO"]
|
108 |
+
cursor = collection.find()
|
109 |
+
|
110 |
+
raw_display = pd.DataFrame(list(cursor))
|
111 |
+
dk_raw = raw_display[['Player', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%',
|
112 |
+
'Own', 'Small_Field_Own', 'Large_Field_Own', 'Cash_Field_Own', 'CPT_Own', 'LevX', 'version', 'slate', 'timestamp', 'player_id', 'site']]
|
113 |
+
dk_raw['STDev'] = (dk_raw['Ceiling'] - dk_raw['Floor']) / 4
|
114 |
+
|
115 |
+
collection = db["FD_NFL_ROO"]
|
116 |
+
cursor = collection.find()
|
117 |
+
|
118 |
+
raw_display = pd.DataFrame(list(cursor))
|
119 |
+
fd_raw = raw_display[['Player', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Ceiling', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%',
|
120 |
+
'Own', 'Small_Field_Own', 'Large_Field_Own', 'Cash_Field_Own', 'CPT_Own', 'LevX', 'version', 'slate', 'timestamp', 'player_id', 'site']]
|
121 |
+
fd_raw['STDev'] = (fd_raw['Ceiling'] - fd_raw['Floor']) / 4
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
return dk_raw, fd_raw
|
124 |
|
|
|
187 |
FD_seed = init_FD_seed_frames()
|
188 |
dk_raw, fd_raw = init_baselines()
|
189 |
|
190 |
+
slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'Secondary Slate'))
|
191 |
site_var1 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'))
|
192 |
if site_var1 == 'Draftkings':
|
193 |
+
if slate_var1 == 'Main Slate':
|
194 |
+
DK_seed = init_DK_seed_frames()
|
195 |
+
elif slate_var1 == 'Secondary Slate':
|
196 |
+
DK_seed = init_DK_Secondary_seed_frames()
|
197 |
+
|
198 |
raw_baselines = dk_raw
|
199 |
column_names = dk_columns
|
200 |
|
|
|
211 |
stack_var2 = [5, 4, 3, 2, 1, 0]
|
212 |
|
213 |
elif site_var1 == 'Fanduel':
|
214 |
+
if slate_var1 == 'Main Slate':
|
215 |
+
FD_seed = init_FD_seed_frames()
|
216 |
+
elif slate_var1 == 'Secondary Slate':
|
217 |
+
FD_seed = init_FD_Secondary_seed_frames()
|
218 |
+
|
219 |
raw_baselines = fd_raw
|
220 |
column_names = fd_columns
|
221 |
|
|
|
279 |
DK_seed = init_DK_seed_frames()
|
280 |
FD_seed = init_FD_seed_frames()
|
281 |
dk_raw, fd_raw = init_baselines()
|
282 |
+
sim_slate_var1 = st.radio("Which data are you loading?", ('Main Slate', 'Secondary Slate'), key='sim_slate_var1')
|
283 |
sim_site_var1 = st.radio("What site are you working with?", ('Draftkings', 'Fanduel'), key='sim_site_var1')
|
284 |
if sim_site_var1 == 'Draftkings':
|
285 |
+
if sim_slate_var1 == 'Main Slate':
|
286 |
+
DK_seed = init_DK_seed_frames()
|
287 |
+
elif sim_slate_var1 == 'Secondary Slate':
|
288 |
+
DK_seed = init_DK_Secondary_seed_frames()
|
289 |
+
|
290 |
raw_baselines = dk_raw
|
291 |
column_names = dk_columns
|
292 |
elif sim_site_var1 == 'Fanduel':
|
293 |
+
if sim_slate_var1 == 'Main Slate':
|
294 |
+
FD_seed = init_FD_seed_frames()
|
295 |
+
elif sim_slate_var1 == 'Secondary Slate':
|
296 |
+
FD_seed = init_FD_Secondary_seed_frames()
|
297 |
+
|
298 |
raw_baselines = fd_raw
|
299 |
column_names = fd_columns
|
300 |
|