Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -26,11 +26,25 @@ def init_conn():
|
|
26 |
client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=100000)
|
27 |
db = client["testing_db"]
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
gc_con = gspread.service_account_from_dict(credentials, scope)
|
30 |
|
31 |
-
return gc_con, client, db
|
32 |
|
33 |
-
gcservice_account, client, db = init_conn()
|
34 |
|
35 |
MLB_Data = 'https://docs.google.com/spreadsheets/d/1f42Ergav8K1VsOLOK9MUn7DM_MLMvv4GR2Fy7EfnZTc/edit#gid=340831852'
|
36 |
|
@@ -56,28 +70,6 @@ def init_baselines():
|
|
56 |
|
57 |
return dk_raw, fd_raw
|
58 |
|
59 |
-
@st.cache_data(ttl = 59)
|
60 |
-
def init_DK_seed_frame():
|
61 |
-
collection = db["DK_MLB_seed_frame"]
|
62 |
-
cursor = collection.find()
|
63 |
-
|
64 |
-
raw_display = pd.DataFrame(list(cursor))
|
65 |
-
raw_display = raw_display[['salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']]
|
66 |
-
DK_seed = raw_display.to_numpy()
|
67 |
-
|
68 |
-
return DK_seed
|
69 |
-
|
70 |
-
@st.cache_data(ttl = 59)
|
71 |
-
def init_FD_seed_frame():
|
72 |
-
collection = db["FD_MLB_seed_frame"]
|
73 |
-
cursor = collection.find()
|
74 |
-
|
75 |
-
raw_display = pd.DataFrame(list(cursor))
|
76 |
-
raw_display = raw_display[['salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL']]
|
77 |
-
FD_seed = raw_display.to_numpy()
|
78 |
-
|
79 |
-
return FD_seed
|
80 |
-
|
81 |
@st.cache_data
|
82 |
def convert_df(array):
|
83 |
array = pd.DataFrame(array, columns=column_names)
|
@@ -140,7 +132,7 @@ with tab1:
|
|
140 |
if st.button("Load Seed Frame", key='seed_frame_load'):
|
141 |
if site_var1 == 'Draftkings':
|
142 |
|
143 |
-
working_seed =
|
144 |
# working_seed_parse = working_seed[np.isin(working_seed[:, 2], team_var2)]
|
145 |
# working_seed_parse = working_seed[np.isin(working_seed[:, 3], stack_var2)]
|
146 |
data_export_display = pd.DataFrame(working_seed[0:1000], columns=column_names)
|
@@ -157,7 +149,7 @@ with tab1:
|
|
157 |
|
158 |
elif site_var1 == 'Fanduel':
|
159 |
|
160 |
-
working_seed =
|
161 |
# working_seed_parse = working_seed[np.isin(working_seed[:, 2], team_var2)]
|
162 |
# working_seed_parse = working_seed[np.isin(working_seed[:, 3], stack_var2)]
|
163 |
data_export_display = pd.DataFrame(working_seed[0:1000], columns=column_names)
|
|
|
26 |
client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=100000)
|
27 |
db = client["testing_db"]
|
28 |
|
29 |
+
collection = db["DK_MLB_seed_frame"]
|
30 |
+
cursor = collection.find()
|
31 |
+
|
32 |
+
raw_display = pd.DataFrame(list(cursor))
|
33 |
+
raw_display = raw_display[['salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'SP1', 'SP2', 'C', '1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3']]
|
34 |
+
DK_seed = raw_display.to_numpy()
|
35 |
+
|
36 |
+
collection = db["FD_MLB_seed_frame"]
|
37 |
+
cursor = collection.find()
|
38 |
+
|
39 |
+
raw_display = pd.DataFrame(list(cursor))
|
40 |
+
raw_display = raw_display[['salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'P', 'C_1B', '2B', '3B', 'SS', 'OF1', 'OF2', 'OF3', 'UTIL']]
|
41 |
+
FD_seed = raw_display.to_numpy()
|
42 |
+
|
43 |
gc_con = gspread.service_account_from_dict(credentials, scope)
|
44 |
|
45 |
+
return gc_con, client, db, DK_seed, FD_seed
|
46 |
|
47 |
+
gcservice_account, client, db, DK_seed, FD_seedb = init_conn()
|
48 |
|
49 |
MLB_Data = 'https://docs.google.com/spreadsheets/d/1f42Ergav8K1VsOLOK9MUn7DM_MLMvv4GR2Fy7EfnZTc/edit#gid=340831852'
|
50 |
|
|
|
70 |
|
71 |
return dk_raw, fd_raw
|
72 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
@st.cache_data
|
74 |
def convert_df(array):
|
75 |
array = pd.DataFrame(array, columns=column_names)
|
|
|
132 |
if st.button("Load Seed Frame", key='seed_frame_load'):
|
133 |
if site_var1 == 'Draftkings':
|
134 |
|
135 |
+
working_seed = DK_seed
|
136 |
# working_seed_parse = working_seed[np.isin(working_seed[:, 2], team_var2)]
|
137 |
# working_seed_parse = working_seed[np.isin(working_seed[:, 3], stack_var2)]
|
138 |
data_export_display = pd.DataFrame(working_seed[0:1000], columns=column_names)
|
|
|
149 |
|
150 |
elif site_var1 == 'Fanduel':
|
151 |
|
152 |
+
working_seed = FD_seed
|
153 |
# working_seed_parse = working_seed[np.isin(working_seed[:, 2], team_var2)]
|
154 |
# working_seed_parse = working_seed[np.isin(working_seed[:, 3], stack_var2)]
|
155 |
data_export_display = pd.DataFrame(working_seed[0:1000], columns=column_names)
|