Spaces:
Running
Running
File size: 18,478 Bytes
ffdc4c9 8d54556 ffdc4c9 a8566d3 ffdc4c9 a8566d3 ffdc4c9 a8566d3 ffdc4c9 ba88186 ffdc4c9 a8566d3 ffdc4c9 a8566d3 ffdc4c9 a8566d3 ffdc4c9 bdec482 ffdc4c9 a8566d3 ffdc4c9 a8566d3 ffdc4c9 a8566d3 ffdc4c9 8d54556 ffdc4c9 174661a ffdc4c9 8d54556 6dbe3a8 ffdc4c9 6dbe3a8 ffdc4c9 8d54556 dd671e4 ffdc4c9 590cd48 5f95eed 11236ec ffdc4c9 8d54556 11236ec ffdc4c9 11236ec ffdc4c9 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 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 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 |
import pandas as pd
import streamlit as st
import gspread
scope = ['https://www.googleapis.com/auth/spreadsheets',
"https://www.googleapis.com/auth/drive"]
credentials = {
"type": "service_account",
"project_id": "sheets-api-connect-378620",
"private_key_id": "1005124050c80d085e2c5b344345715978dd9cc9",
"private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCtKa01beXwc88R\nnPZVQTNPVQuBnbwoOfc66gW3547ja/UEyIGAF112dt/VqHprRafkKGmlg55jqJNt\na4zceLKV+wTm7vBu7lDISTJfGzCf2TrxQYNqwMKE2LOjI69dBM8u4Dcb4k0wcp9v\ntW1ZzLVVuwTvmrg7JBHjiSaB+x5wxm/r3FOiJDXdlAgFlytzqgcyeZMJVKKBQHyJ\njEGg/1720A0numuOCt71w/2G0bDmijuj1e6tH32MwRWcvRNZ19K9ssyDz2S9p68s\nYDhIxX69OWxwScTIHLY6J2t8txf/XMivL/636fPlDADvBEVTdlT606n8CcKUVQeq\npUVdG+lfAgMBAAECggEAP38SUA7B69eTfRpo658ycOs3Amr0JW4H/bb1rNeAul0K\nZhwd/HnU4E07y81xQmey5kN5ZeNrD5EvqkZvSyMJHV0EEahZStwhjCfnDB/cxyix\nZ+kFhv4y9eK+kFpUAhBy5nX6T0O+2T6WvzAwbmbVsZ+X8kJyPuF9m8ldcPlD0sce\ntj8NwVq1ys52eosqs7zi2vjt+eMcaY393l4ls+vNq8Yf27cfyFw45W45CH/97/Nu\n5AmuzlCOAfFF+z4OC5g4rei4E/Qgpxa7/uom+BVfv9G0DIGW/tU6Sne0+37uoGKt\nW6DzhgtebUtoYkG7ZJ05BTXGp2lwgVcNRoPwnKJDxQKBgQDT5wYPUBDW+FHbvZSp\nd1m1UQuXyerqOTA9smFaM8sr/UraeH85DJPEIEk8qsntMBVMhvD3Pw8uIUeFNMYj\naLmZFObsL+WctepXrVo5NB6RtLB/jZYxiKMatMLUJIYtcKIp+2z/YtKiWcLnwotB\nWdCjVnPTxpkurmF2fWP/eewZ+wKBgQDRMtJg7etjvKyjYNQ5fARnCc+XsI3gkBe1\nX9oeXfhyfZFeBXWnZzN1ITgFHplDznmBdxAyYGiQdbbkdKQSghviUQ0igBvoDMYy\n1rWcy+a17Mj98uyNEfmb3X2cC6WpvOZaGHwg9+GY67BThwI3FqHIbyk6Ko09WlTX\nQpRQjMzU7QKBgAfi1iflu+q0LR+3a3vvFCiaToskmZiD7latd9AKk2ocsBd3Woy9\n+hXXecJHPOKV4oUJlJgvAZqe5HGBqEoTEK0wyPNLSQlO/9ypd+0fEnArwFHO7CMF\nycQprAKHJXM1eOOFFuZeQCaInqdPZy1UcV5Szla4UmUZWkk1m24blHzXAoGBAMcA\nyH4qdbxX9AYrC1dvsSRvgcnzytMvX05LU0uF6tzGtG0zVlub4ahvpEHCfNuy44UT\nxRWW/oFFaWjjyFxO5sWggpUqNuHEnRopg3QXx22SRRTGbN45li/+QAocTkgsiRh1\nqEcYZsO4mPCsQqAy6E2p6RcK+Xa+omxvSnVhq0x1AoGAKr8GdkCl4CF6rieLMAQ7\nLNBuuoYGaHoh8l5E2uOQpzwxVy/nMBcAv+2+KqHEzHryUv1owOi6pMLv7A9mTFoS\n18B0QRLuz5fSOsVnmldfC9fpUc6H8cH1SINZpzajqQA74bPwELJjnzrCnH79TnHG\nJuElxA33rFEjbgbzdyrE768=\n-----END PRIVATE KEY-----\n",
"client_email": "gspread-connection@sheets-api-connect-378620.iam.gserviceaccount.com",
"client_id": "106625872877651920064",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/gspread-connection%40sheets-api-connect-378620.iam.gserviceaccount.com"
}
gc = gspread.service_account_from_dict(credentials)
st.set_page_config(layout="wide")
@st.cache_data
def init_baselines():
sh = gc.open_by_url('https://docs.google.com/spreadsheets/d/10MVGsAHJPUAdK9SJ28ZqjgBgV2xBJSXEka-s2pIxHHE/edit#gid=1858245367')
worksheet = sh.worksheet('ROO')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Player'] != 'Welp']
raw_display = raw_display.loc[raw_display['Salary'] > 0]
raw_display = raw_display.loc[raw_display['Median'] > 0]
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
roo_table = raw_display.sort_values(by='Median', ascending=False)
# worksheet = sh.worksheet('Positional_Boosts')
# raw_display = pd.DataFrame(worksheet.get_all_records())
# raw_display.replace("", 'Welp', inplace=True)
# raw_display = raw_display.loc[raw_display['teamname'] != 'Welp']
# raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
# positional_boosts = raw_display.sort_values(by='Avg_Allowed', ascending=False)
worksheet = sh.worksheet('Overall_Stacks')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Team'] != 'Welp']
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
lck_overall_stacks = raw_display.sort_values(by='Stack+', ascending=False)
worksheet = sh.worksheet('Win_Stacks')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Team'] != 'Welp']
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
lck_win_stacks = raw_display.sort_values(by='Stack+', ascending=False)
worksheet = sh.worksheet('Loss_Stacks')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Team'] != 'Welp']
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
lck_loss_stacks = raw_display.sort_values(by='Stack+', ascending=False)
worksheet = sh.worksheet('Overall_BO1_Stats')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Player'] != 'Welp']
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
lck_bo1 = raw_display
worksheet = sh.worksheet('Overall_BO3_Stats')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Player'] != 'Welp']
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
lck_bo3 = raw_display
worksheet = sh.worksheet('Overall_BO5_Stats')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Player'] != 'Welp']
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
lck_bo5 = raw_display
sh = gc.open_by_url('https://docs.google.com/spreadsheets/d/10MVGsAHJPUAdK9SJ28ZqjgBgV2xBJSXEka-s2pIxHHE/edit#gid=1858245367')
worksheet = sh.worksheet('Overall_Stacks')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Team'] != 'Welp']
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
lcs_overall_stacks = raw_display.sort_values(by='Stack+', ascending=False)
worksheet = sh.worksheet('Win_Stacks')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Team'] != 'Welp']
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
lcs_win_stacks = raw_display.sort_values(by='Stack+', ascending=False)
worksheet = sh.worksheet('Loss_Stacks')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Team'] != 'Welp']
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
lcs_loss_stacks = raw_display.sort_values(by='Stack+', ascending=False)
worksheet = sh.worksheet('Overall_BO1_Stats')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Player'] != 'Welp']
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
lcs_bo1 = raw_display
worksheet = sh.worksheet('Overall_BO3_Stats')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Player'] != 'Welp']
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
lcs_bo3 = raw_display
worksheet = sh.worksheet('Overall_BO5_Stats')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Player'] != 'Welp']
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
lcs_bo5 = raw_display
sh = gc.open_by_url('https://docs.google.com/spreadsheets/d/1oOJD_QcBeDJ1f7e9FfgUHOQEPT6kvU0Sa9hQ_4B8gqc/edit?gid=1288836099#gid=1288836099')
worksheet = sh.worksheet('Overall_Stacks')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Team'] != 'Welp']
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
lec_overall_stacks = raw_display.sort_values(by='Stack+', ascending=False)
worksheet = sh.worksheet('Win_Stacks')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Team'] != 'Welp']
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
lec_win_stacks = raw_display.sort_values(by='Stack+', ascending=False)
worksheet = sh.worksheet('Loss_Stacks')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Team'] != 'Welp']
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
lec_loss_stacks = raw_display.sort_values(by='Stack+', ascending=False)
worksheet = sh.worksheet('Overall_BO1_Stats')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Player'] != 'Welp']
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
lec_bo1 = raw_display
worksheet = sh.worksheet('Overall_BO3_Stats')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Player'] != 'Welp']
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
lec_bo3 = raw_display
worksheet = sh.worksheet('Overall_BO5_Stats')
raw_display = pd.DataFrame(worksheet.get_all_records())
raw_display.rename(columns={"Name": "Player", "Nickname": "Player", "Fantasy": "Median"}, inplace = True)
raw_display.replace("", 'Welp', inplace=True)
raw_display = raw_display.loc[raw_display['Player'] != 'Welp']
raw_display = raw_display.apply(pd.to_numeric, errors='ignore')
lec_bo5 = raw_display
return roo_table, lck_overall_stacks, lck_win_stacks, lck_loss_stacks, lcs_overall_stacks, lcs_win_stacks, lcs_loss_stacks, lec_overall_stacks, lec_win_stacks, lec_loss_stacks, lck_bo1, lck_bo3, lck_bo5, lcs_bo1, lcs_bo3, lcs_bo5, lec_bo1, lec_bo3, lec_bo5
roo_table, lck_overall_stacks, lck_win_stacks, lck_loss_stacks, lcs_overall_stacks, lcs_win_stacks, lcs_loss_stacks, lec_overall_stacks, lec_win_stacks, lec_loss_stacks, lck_bo1, lck_bo3, lck_bo5, lcs_bo1, lcs_bo3, lcs_bo5, lec_bo1, lec_bo3, lec_bo5 = init_baselines()
tab1, tab2, tab3 = st.tabs(["LOL Stacks Table", "LOL Range of Outcomes", "LOL Player Base Stats"])
def convert_df_to_csv(df):
return df.to_csv().encode('utf-8')
with tab1:
if st.button("Reset Data", key='reset1'):
# Clear values from *all* all in-memory and on-disk data caches:
# i.e. clear values from both square and cube
st.cache_data.clear()
roo_table, lck_overall_stacks, lck_win_stacks, lck_loss_stacks, lcs_overall_stacks, lcs_win_stacks, lcs_loss_stacks, lec_overall_stacks, lec_win_stacks, lec_loss_stacks, lck_bo1, lck_bo3, lck_bo5, lcs_bo1, lcs_bo3, lcs_bo5, lec_bo1, lec_bo3, lec_bo5 = init_baselines()
league_choice1 = st.radio("What table would you like to display?", ('LCK/LPL', 'LCS', 'LEC'), key='league_var1')
if league_choice1 == 'LCK/LPL':
league_hold = lck_overall_stacks
elif league_choice1 == 'LCS':
league_hold = lcs_overall_stacks
elif league_choice1 == 'LEC':
league_hold = lec_overall_stacks
display = league_hold.set_index('Team')
st.dataframe(display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), use_container_width = True)
st.download_button(
label="Export Stacks",
data=convert_df_to_csv(display),
file_name='LOL_Stacks_export.csv',
mime='text/csv',
)
with tab2:
if st.button("Reset Data", key='reset2'):
# Clear values from *all* all in-memory and on-disk data caches:
# i.e. clear values from both square and cube
st.cache_data.clear()
roo_table, lck_overall_stacks, lck_win_stacks, lck_loss_stacks, lcs_overall_stacks, lcs_win_stacks, lcs_loss_stacks, lec_overall_stacks, lec_win_stacks, lec_loss_stacks, lck_bo1, lck_bo3, lck_bo5, lcs_bo1, lcs_bo3, lcs_bo5, lec_bo1, lec_bo3, lec_bo5 = init_baselines()
with st.container():
col1, col2, col3, col4 = st.columns([4, 2, 2, 2])
with col1:
league_choice2 = st.radio("What table would you like to display?", ('LCK/LPL', 'LCS', 'LEC'), key='league_var2')
if league_choice2 == 'LCK/LPL':
league_hold = roo_table[roo_table['league'] == 'LCK']
elif league_choice2 == 'LCS':
league_hold = roo_table[roo_table['league'] == 'LCS']
elif league_choice2 == 'LEC':
league_hold = roo_table[roo_table['league'] == 'LEC']
with col2:
model_choice = st.radio("What table would you like to display?", ('Overall', 'Wins', 'Losses'), key='roo_table')
if model_choice == 'Overall':
hold_display = league_hold[league_hold['type'] == 'Overall']
elif model_choice == 'Wins':
hold_display = league_hold[league_hold['type'] == 'Wins']
elif model_choice == 'Losses':
hold_display = league_hold[league_hold['type'] == 'Losses']
with col3:
pos_var1 = st.selectbox('View specific position?', options = ['All', 'TOP', 'JNG', 'MID', 'ADC', 'SUP'], key = 'roo_posvar')
with col4:
team_var1 = st.multiselect('View specific team?', options = hold_display['Team'].unique(), key = 'roo_teamvar')
display = hold_display.set_index('Player')
if team_var1:
display = display[display['Team'].isin(team_var1)]
if pos_var1 == 'All':
display = display
elif pos_var1 != 'All':
display = display[display['Position'].str.contains(pos_var1)]
display = display.drop(columns=['type', 'league', 'Timestamp'])
display['Cpt_Own'] = ((display['Own']) * ((100 - (100-display['Own'])))) / 100
st.dataframe(display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), height=750, use_container_width = True)
st.download_button(
label="Export Range of Outcomes",
data=convert_df_to_csv(display),
file_name='LOL_ROO_export.csv',
mime='text/csv',
)
with tab3:
if st.button("Reset Data", key='reset3'):
# Clear values from *all* all in-memory and on-disk data caches:
# i.e. clear values from both square and cube
st.cache_data.clear()
roo_table, lck_overall_stacks, lck_win_stacks, lck_loss_stacks, lcs_overall_stacks, lcs_win_stacks, lcs_loss_stacks, lec_overall_stacks, lec_win_stacks, lec_loss_stacks, lck_bo1, lck_bo3, lck_bo5, lcs_bo1, lcs_bo3, lcs_bo5, lec_bo1, lec_bo3, lec_bo5 = init_baselines()
with st.container():
col1, col2, col3, col4 = st.columns([4, 2, 2, 2])
with col1:
league_choice3 = st.radio("What table would you like to display?", ('LCK/LPL', 'LCS', 'LEC'), key='league_var3')
with col2:
gametype_choice = st.radio("What format are the games being played?", ('Best of 1', 'Best of 3', 'Best of 5'), key='player_stats')
with col3:
pos_var2 = st.selectbox('View specific position?', options = ['All', 'TOP', 'JNG', 'MID', 'ADC', 'SUP'], key = 'proj_posvar')
with col4:
team_var2 = st.multiselect('View specific team?', options = hold_display['Team'].unique(), key = 'proj_teamvar')
if league_choice3 == 'LCK/LPL':
if gametype_choice == 'Best of 1':
hold_display = lck_bo1
elif gametype_choice == 'Best of 3':
hold_display = lck_bo3
elif gametype_choice == 'Best of 5':
hold_display = lck_bo5
display = hold_display.set_index('Player')
elif league_choice3 == 'LCS':
if gametype_choice == 'Best of 1':
hold_display = lcs_bo1
elif gametype_choice == 'Best of 3':
hold_display = lcs_bo3
elif gametype_choice == 'Best of 5':
hold_display = lcs_bo5
display = hold_display.set_index('Player')
elif league_choice3 == 'LEC':
if gametype_choice == 'Best of 1':
hold_display = lec_bo1
elif gametype_choice == 'Best of 3':
hold_display = lec_bo3
elif gametype_choice == 'Best of 5':
hold_display = lec_bo5
display = hold_display.set_index('Player')
if team_var2:
display = display[display['Team'].isin(team_var2)]
if pos_var2 == 'All':
display = display
elif pos_var2 != 'All':
display = display[display['Position'].str.contains(pos_var2)]
st.dataframe(display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(precision=2), height=750, use_container_width = True)
st.download_button(
label="Export Baselines",
data=convert_df_to_csv(display),
file_name='LOL_Baselines_export.csv',
mime='text/csv',
) |