Spaces:
Sleeping
Sleeping
James McCool
commited on
Commit
·
02183a0
1
Parent(s):
3dc7dac
Added backlog option to display, collection limit of 10k on seed frame
Browse files
app.py
CHANGED
|
@@ -63,7 +63,6 @@ def load_overall_stats():
|
|
| 63 |
worksheet = sh.worksheet('DK_Build_Up')
|
| 64 |
raw_display = pd.DataFrame(worksheet.get_all_records())
|
| 65 |
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
|
| 66 |
-
raw_display.replace("", 'Welp', inplace=True)
|
| 67 |
raw_display = raw_display.loc[raw_display['Salary'] > 0]
|
| 68 |
raw_display = raw_display.loc[raw_display['Median'] > 0]
|
| 69 |
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
|
|
@@ -72,7 +71,6 @@ def load_overall_stats():
|
|
| 72 |
worksheet = sh.worksheet('FD_Build_Up')
|
| 73 |
raw_display = pd.DataFrame(worksheet.get_all_records())
|
| 74 |
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
|
| 75 |
-
raw_display.replace("", 'Welp', inplace=True)
|
| 76 |
raw_display = raw_display.loc[raw_display['Median'] > 0]
|
| 77 |
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
|
| 78 |
fd_raw = raw_display.sort_values(by='Median', ascending=False)
|
|
@@ -80,7 +78,6 @@ def load_overall_stats():
|
|
| 80 |
worksheet = sh.worksheet('Secondary_DK_Build')
|
| 81 |
raw_display = pd.DataFrame(worksheet.get_all_records())
|
| 82 |
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
|
| 83 |
-
raw_display.replace("", 'Welp', inplace=True)
|
| 84 |
raw_display = raw_display.loc[raw_display['Median'] > 0]
|
| 85 |
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
|
| 86 |
dk_raw_sec = raw_display.sort_values(by='Median', ascending=False)
|
|
@@ -88,31 +85,33 @@ def load_overall_stats():
|
|
| 88 |
worksheet = sh.worksheet('Secondary_FD_Build')
|
| 89 |
raw_display = pd.DataFrame(worksheet.get_all_records())
|
| 90 |
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
|
| 91 |
-
raw_display.replace("", 'Welp', inplace=True)
|
| 92 |
raw_display = raw_display.loc[raw_display['Median'] > 0]
|
| 93 |
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
|
| 94 |
fd_raw_sec = raw_display.sort_values(by='Median', ascending=False)
|
| 95 |
|
| 96 |
worksheet = sh.worksheet('Player_Level_ROO')
|
| 97 |
raw_display = pd.DataFrame(worksheet.get_all_records())
|
| 98 |
-
raw_display.replace("", 'Welp', inplace=True)
|
| 99 |
raw_display = raw_display.loc[raw_display['Median'] > 0]
|
| 100 |
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
|
| 101 |
roo_raw = raw_display.sort_values(by='Median', ascending=False)
|
| 102 |
|
| 103 |
timestamp = raw_display['timestamp'].values[0]
|
| 104 |
|
| 105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 106 |
|
| 107 |
@st.cache_data(ttl = 300)
|
| 108 |
def init_DK_lineups():
|
| 109 |
|
| 110 |
collection = db["DK_NBA_seed_frame"]
|
| 111 |
-
cursor = collection.find()
|
| 112 |
|
| 113 |
raw_display = pd.DataFrame(list(cursor))
|
| 114 |
raw_display = raw_display[['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'FLEX', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 115 |
-
DK_seed = raw_display.
|
| 116 |
|
| 117 |
return DK_seed
|
| 118 |
|
|
@@ -120,11 +119,11 @@ def init_DK_lineups():
|
|
| 120 |
def init_FD_lineups():
|
| 121 |
|
| 122 |
collection = db["FD_NBA_seed_frame"]
|
| 123 |
-
cursor = collection.find()
|
| 124 |
|
| 125 |
raw_display = pd.DataFrame(list(cursor))
|
| 126 |
raw_display = raw_display[['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 127 |
-
FD_seed = raw_display.
|
| 128 |
|
| 129 |
return FD_seed
|
| 130 |
|
|
@@ -136,7 +135,7 @@ def convert_df(array):
|
|
| 136 |
array = pd.DataFrame(array, columns=column_names)
|
| 137 |
return array.to_csv().encode('utf-8')
|
| 138 |
|
| 139 |
-
dk_raw, fd_raw, dk_raw_sec, fd_raw_sec, roo_raw, timestamp = load_overall_stats()
|
| 140 |
dk_lineups = init_DK_lineups()
|
| 141 |
fd_lineups = init_FD_lineups()
|
| 142 |
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
|
@@ -151,7 +150,7 @@ with tab1:
|
|
| 151 |
st.info(t_stamp)
|
| 152 |
if st.button("Load/Reset Data", key='reset1'):
|
| 153 |
st.cache_data.clear()
|
| 154 |
-
dk_raw, fd_raw, dk_raw_sec, fd_raw_sec, roo_raw, timestamp = load_overall_stats()
|
| 155 |
dk_lineups = init_DK_lineups()
|
| 156 |
fd_lineups = init_FD_lineups()
|
| 157 |
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
|
@@ -162,11 +161,14 @@ with tab1:
|
|
| 162 |
site_baselines = roo_raw[roo_raw['site'] == 'Draftkings']
|
| 163 |
elif site_var2 == 'Fanduel':
|
| 164 |
site_baselines = roo_raw[roo_raw['site'] == 'Fanduel']
|
| 165 |
-
slate_split = st.radio("Are you viewing the main slate or the secondary slate?", ('Main Slate', 'Secondary'), key='slate_split')
|
| 166 |
if slate_split == 'Main Slate':
|
| 167 |
raw_baselines = site_baselines[site_baselines['slate'] == 'Main Slate']
|
| 168 |
elif slate_split == 'Secondary':
|
| 169 |
raw_baselines = site_baselines[site_baselines['slate'] == 'Secondary Slate']
|
|
|
|
|
|
|
|
|
|
| 170 |
split_var2 = st.radio("Are you running the full slate or certain games?", ('Full Slate Run', 'Specific Games'), key='split_var2')
|
| 171 |
if split_var2 == 'Specific Games':
|
| 172 |
team_var2 = st.multiselect('Which teams would you like to include in the ROO?', options = raw_baselines['Team'].unique(), key='team_var2')
|
|
@@ -206,7 +208,7 @@ with tab2:
|
|
| 206 |
with col1:
|
| 207 |
if st.button("Load/Reset Data", key='reset2'):
|
| 208 |
st.cache_data.clear()
|
| 209 |
-
dk_raw, fd_raw, dk_raw_sec, fd_raw_sec, roo_raw, timestamp = load_overall_stats()
|
| 210 |
dk_lineups = init_DK_lineups()
|
| 211 |
fd_lineups = init_FD_lineups()
|
| 212 |
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
|
|
|
| 63 |
worksheet = sh.worksheet('DK_Build_Up')
|
| 64 |
raw_display = pd.DataFrame(worksheet.get_all_records())
|
| 65 |
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
|
|
|
|
| 66 |
raw_display = raw_display.loc[raw_display['Salary'] > 0]
|
| 67 |
raw_display = raw_display.loc[raw_display['Median'] > 0]
|
| 68 |
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
|
|
|
|
| 71 |
worksheet = sh.worksheet('FD_Build_Up')
|
| 72 |
raw_display = pd.DataFrame(worksheet.get_all_records())
|
| 73 |
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
|
|
|
|
| 74 |
raw_display = raw_display.loc[raw_display['Median'] > 0]
|
| 75 |
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
|
| 76 |
fd_raw = raw_display.sort_values(by='Median', ascending=False)
|
|
|
|
| 78 |
worksheet = sh.worksheet('Secondary_DK_Build')
|
| 79 |
raw_display = pd.DataFrame(worksheet.get_all_records())
|
| 80 |
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
|
|
|
|
| 81 |
raw_display = raw_display.loc[raw_display['Median'] > 0]
|
| 82 |
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
|
| 83 |
dk_raw_sec = raw_display.sort_values(by='Median', ascending=False)
|
|
|
|
| 85 |
worksheet = sh.worksheet('Secondary_FD_Build')
|
| 86 |
raw_display = pd.DataFrame(worksheet.get_all_records())
|
| 87 |
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
|
|
|
|
| 88 |
raw_display = raw_display.loc[raw_display['Median'] > 0]
|
| 89 |
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
|
| 90 |
fd_raw_sec = raw_display.sort_values(by='Median', ascending=False)
|
| 91 |
|
| 92 |
worksheet = sh.worksheet('Player_Level_ROO')
|
| 93 |
raw_display = pd.DataFrame(worksheet.get_all_records())
|
|
|
|
| 94 |
raw_display = raw_display.loc[raw_display['Median'] > 0]
|
| 95 |
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
|
| 96 |
roo_raw = raw_display.sort_values(by='Median', ascending=False)
|
| 97 |
|
| 98 |
timestamp = raw_display['timestamp'].values[0]
|
| 99 |
|
| 100 |
+
worksheet = sh.worksheet('ROO_backlog')
|
| 101 |
+
raw_display = pd.DataFrame(worksheet.get_all_records())
|
| 102 |
+
roo_backlog = raw_display.sort_values(by='Median', ascending=False)
|
| 103 |
+
|
| 104 |
+
return dk_raw, fd_raw, dk_raw_sec, fd_raw_sec, roo_raw, timestamp, roo_backlog
|
| 105 |
|
| 106 |
@st.cache_data(ttl = 300)
|
| 107 |
def init_DK_lineups():
|
| 108 |
|
| 109 |
collection = db["DK_NBA_seed_frame"]
|
| 110 |
+
cursor = collection.find().limit(10000)
|
| 111 |
|
| 112 |
raw_display = pd.DataFrame(list(cursor))
|
| 113 |
raw_display = raw_display[['PG', 'SG', 'SF', 'PF', 'C', 'G', 'F', 'FLEX', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 114 |
+
DK_seed = raw_display.to_numpy()
|
| 115 |
|
| 116 |
return DK_seed
|
| 117 |
|
|
|
|
| 119 |
def init_FD_lineups():
|
| 120 |
|
| 121 |
collection = db["FD_NBA_seed_frame"]
|
| 122 |
+
cursor = collection.find().limit(10000)
|
| 123 |
|
| 124 |
raw_display = pd.DataFrame(list(cursor))
|
| 125 |
raw_display = raw_display[['PG1', 'PG2', 'SG1', 'SG2', 'SF1', 'SF2', 'PF1', 'PF2', 'C1', 'salary', 'proj', 'Team', 'Team_count', 'Secondary', 'Secondary_count', 'Own']]
|
| 126 |
+
FD_seed = raw_display.to_numpy()
|
| 127 |
|
| 128 |
return FD_seed
|
| 129 |
|
|
|
|
| 135 |
array = pd.DataFrame(array, columns=column_names)
|
| 136 |
return array.to_csv().encode('utf-8')
|
| 137 |
|
| 138 |
+
dk_raw, fd_raw, dk_raw_sec, fd_raw_sec, roo_raw, timestamp, roo_backlog = load_overall_stats()
|
| 139 |
dk_lineups = init_DK_lineups()
|
| 140 |
fd_lineups = init_FD_lineups()
|
| 141 |
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
|
|
|
| 150 |
st.info(t_stamp)
|
| 151 |
if st.button("Load/Reset Data", key='reset1'):
|
| 152 |
st.cache_data.clear()
|
| 153 |
+
dk_raw, fd_raw, dk_raw_sec, fd_raw_sec, roo_raw, timestamp, roo_backlog = load_overall_stats()
|
| 154 |
dk_lineups = init_DK_lineups()
|
| 155 |
fd_lineups = init_FD_lineups()
|
| 156 |
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|
|
|
|
| 161 |
site_baselines = roo_raw[roo_raw['site'] == 'Draftkings']
|
| 162 |
elif site_var2 == 'Fanduel':
|
| 163 |
site_baselines = roo_raw[roo_raw['site'] == 'Fanduel']
|
| 164 |
+
slate_split = st.radio("Are you viewing the main slate or the secondary slate?", ('Main Slate', 'Secondary', 'Backlog'), key='slate_split')
|
| 165 |
if slate_split == 'Main Slate':
|
| 166 |
raw_baselines = site_baselines[site_baselines['slate'] == 'Main Slate']
|
| 167 |
elif slate_split == 'Secondary':
|
| 168 |
raw_baselines = site_baselines[site_baselines['slate'] == 'Secondary Slate']
|
| 169 |
+
elif slate_split == 'Backlog':
|
| 170 |
+
raw_baselines = roo_backlog
|
| 171 |
+
raw_baselines = raw_baselines[site_baselines['site'] == site_var2]
|
| 172 |
split_var2 = st.radio("Are you running the full slate or certain games?", ('Full Slate Run', 'Specific Games'), key='split_var2')
|
| 173 |
if split_var2 == 'Specific Games':
|
| 174 |
team_var2 = st.multiselect('Which teams would you like to include in the ROO?', options = raw_baselines['Team'].unique(), key='team_var2')
|
|
|
|
| 208 |
with col1:
|
| 209 |
if st.button("Load/Reset Data", key='reset2'):
|
| 210 |
st.cache_data.clear()
|
| 211 |
+
dk_raw, fd_raw, dk_raw_sec, fd_raw_sec, roo_raw, timestamp, roo_backlog = load_overall_stats()
|
| 212 |
dk_lineups = init_DK_lineups()
|
| 213 |
fd_lineups = init_FD_lineups()
|
| 214 |
t_stamp = f"Last Update: " + str(timestamp) + f" CST"
|