Spaces:
Running
Running
James McCool
commited on
Commit
·
42e86d5
1
Parent(s):
3ec34fb
Removing need for NFL_Data source and using strictly mongo
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,66 @@ 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 |
-
worksheet = sh.worksheet('FD_ROO')
|
| 97 |
-
load_display = pd.DataFrame(worksheet.get_all_records())
|
| 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 |
|
|
|
|
| 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', 'Cei', '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 |
+
|
| 114 |
+
collection = db["FD_NFL_ROO"]
|
| 115 |
+
cursor = collection.find()
|
| 116 |
+
|
| 117 |
+
raw_display = pd.DataFrame(list(cursor))
|
| 118 |
+
fd_raw = raw_display[['Player', 'Position', 'Team', 'Opp', 'Salary', 'Floor', 'Median', 'Cei', 'Top_finish', 'Top_5_finish', 'Top_10_finish', '20+%', '2x%', '3x%', '4x%',
|
| 119 |
+
'Own', 'Small_Field_Own', 'Large_Field_Own', 'Cash_Field_Own', 'CPT_Own', 'LevX', 'version', 'slate', 'timestamp', 'player_id', 'site']]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
return dk_raw, fd_raw
|
| 122 |
|