Spaces:
Sleeping
Sleeping
Rename streamlit_app (2).py to app.py
Browse files- streamlit_app (2).py → app.py +33 -23
streamlit_app (2).py → app.py
RENAMED
|
@@ -1,3 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import pulp
|
| 2 |
import numpy as np
|
| 3 |
import pandas as pd
|
|
@@ -5,25 +12,28 @@ import streamlit as st
|
|
| 5 |
import gspread
|
| 6 |
from itertools import combinations
|
| 7 |
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
| 23 |
|
| 24 |
-
gc = gspread.service_account_from_dict(credentials)
|
|
|
|
| 25 |
|
| 26 |
-
|
| 27 |
|
| 28 |
game_format = {'Win Percentage': '{:.2%}','First Inning Lead Percentage': '{:.2%}',
|
| 29 |
'Fifth Inning Lead Percentage': '{:.2%}', '8+ runs': '{:.2%}', 'DK LevX': '{:.2%}', 'FD LevX': '{:.2%}'}
|
|
@@ -33,7 +43,7 @@ player_roo_format = {'Top_finish': '{:.2%}','Top_5_finish': '{:.2%}', 'Top_10_fi
|
|
| 33 |
|
| 34 |
all_dk_player_projections = 'https://docs.google.com/spreadsheets/d/1I_1Ve3F4tftgfLQQoRKOJ351XfEG48s36OxXUKxmgS8/edit#gid=1391856348'
|
| 35 |
|
| 36 |
-
@st.
|
| 37 |
def set_slate_teams():
|
| 38 |
sh = gc.open_by_url(all_dk_player_projections)
|
| 39 |
worksheet = sh.worksheet('Site_Info')
|
|
@@ -41,7 +51,7 @@ def set_slate_teams():
|
|
| 41 |
|
| 42 |
return raw_display
|
| 43 |
|
| 44 |
-
@st.
|
| 45 |
def player_stat_table():
|
| 46 |
sh = gc.open_by_url(all_dk_player_projections)
|
| 47 |
worksheet = sh.worksheet('Player_Projections')
|
|
@@ -49,7 +59,7 @@ def player_stat_table():
|
|
| 49 |
|
| 50 |
return raw_display
|
| 51 |
|
| 52 |
-
@st.
|
| 53 |
def load_dk_player_projections():
|
| 54 |
sh = gc.open_by_url(all_dk_player_projections)
|
| 55 |
worksheet = sh.worksheet('DK_ROO')
|
|
@@ -59,7 +69,7 @@ def load_dk_player_projections():
|
|
| 59 |
|
| 60 |
return raw_display
|
| 61 |
|
| 62 |
-
@st.
|
| 63 |
def load_fd_player_projections():
|
| 64 |
sh = gc.open_by_url(all_dk_player_projections)
|
| 65 |
worksheet = sh.worksheet('FD_ROO')
|
|
@@ -69,7 +79,7 @@ def load_fd_player_projections():
|
|
| 69 |
|
| 70 |
return raw_display
|
| 71 |
|
| 72 |
-
@st.
|
| 73 |
def load_dk_stacks():
|
| 74 |
sh = gc.open_by_url(all_dk_player_projections)
|
| 75 |
worksheet = sh.worksheet('DK_Stacks')
|
|
@@ -78,7 +88,7 @@ def load_dk_stacks():
|
|
| 78 |
|
| 79 |
return raw_display
|
| 80 |
|
| 81 |
-
@st.
|
| 82 |
def load_fd_stacks():
|
| 83 |
sh = gc.open_by_url(all_dk_player_projections)
|
| 84 |
worksheet = sh.worksheet('FD_Stacks')
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
st.set_page_config(layout="wide")
|
| 3 |
+
|
| 4 |
+
for name in dir():
|
| 5 |
+
if not name.startswith('_'):
|
| 6 |
+
del globals()[name]
|
| 7 |
+
|
| 8 |
import pulp
|
| 9 |
import numpy as np
|
| 10 |
import pandas as pd
|
|
|
|
| 12 |
import gspread
|
| 13 |
from itertools import combinations
|
| 14 |
|
| 15 |
+
@st.cache_resource
|
| 16 |
+
def init_conn():
|
| 17 |
+
scope = ['https://www.googleapis.com/auth/spreadsheets',
|
| 18 |
+
"https://www.googleapis.com/auth/drive"]
|
| 19 |
+
|
| 20 |
+
credentials = {
|
| 21 |
+
"type": "service_account",
|
| 22 |
+
"project_id": "sheets-api-connect-378620",
|
| 23 |
+
"private_key_id": "1005124050c80d085e2c5b344345715978dd9cc9",
|
| 24 |
+
"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",
|
| 25 |
+
"client_email": "gspread-connection@sheets-api-connect-378620.iam.gserviceaccount.com",
|
| 26 |
+
"client_id": "106625872877651920064",
|
| 27 |
+
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
|
| 28 |
+
"token_uri": "https://oauth2.googleapis.com/token",
|
| 29 |
+
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
|
| 30 |
+
"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/gspread-connection%40sheets-api-connect-378620.iam.gserviceaccount.com"
|
| 31 |
+
}
|
| 32 |
|
| 33 |
+
gc = gspread.service_account_from_dict(credentials)
|
| 34 |
+
return gc
|
| 35 |
|
| 36 |
+
gc = init_conn()
|
| 37 |
|
| 38 |
game_format = {'Win Percentage': '{:.2%}','First Inning Lead Percentage': '{:.2%}',
|
| 39 |
'Fifth Inning Lead Percentage': '{:.2%}', '8+ runs': '{:.2%}', 'DK LevX': '{:.2%}', 'FD LevX': '{:.2%}'}
|
|
|
|
| 43 |
|
| 44 |
all_dk_player_projections = 'https://docs.google.com/spreadsheets/d/1I_1Ve3F4tftgfLQQoRKOJ351XfEG48s36OxXUKxmgS8/edit#gid=1391856348'
|
| 45 |
|
| 46 |
+
@st.cache_resource(ttl=3600)
|
| 47 |
def set_slate_teams():
|
| 48 |
sh = gc.open_by_url(all_dk_player_projections)
|
| 49 |
worksheet = sh.worksheet('Site_Info')
|
|
|
|
| 51 |
|
| 52 |
return raw_display
|
| 53 |
|
| 54 |
+
@st.cache_resource(ttl=600)
|
| 55 |
def player_stat_table():
|
| 56 |
sh = gc.open_by_url(all_dk_player_projections)
|
| 57 |
worksheet = sh.worksheet('Player_Projections')
|
|
|
|
| 59 |
|
| 60 |
return raw_display
|
| 61 |
|
| 62 |
+
@st.cache_resource(ttl=600)
|
| 63 |
def load_dk_player_projections():
|
| 64 |
sh = gc.open_by_url(all_dk_player_projections)
|
| 65 |
worksheet = sh.worksheet('DK_ROO')
|
|
|
|
| 69 |
|
| 70 |
return raw_display
|
| 71 |
|
| 72 |
+
@st.cache_resource(ttl=600)
|
| 73 |
def load_fd_player_projections():
|
| 74 |
sh = gc.open_by_url(all_dk_player_projections)
|
| 75 |
worksheet = sh.worksheet('FD_ROO')
|
|
|
|
| 79 |
|
| 80 |
return raw_display
|
| 81 |
|
| 82 |
+
@st.cache_resource(ttl=600)
|
| 83 |
def load_dk_stacks():
|
| 84 |
sh = gc.open_by_url(all_dk_player_projections)
|
| 85 |
worksheet = sh.worksheet('DK_Stacks')
|
|
|
|
| 88 |
|
| 89 |
return raw_display
|
| 90 |
|
| 91 |
+
@st.cache_resource(ttl=600)
|
| 92 |
def load_fd_stacks():
|
| 93 |
sh = gc.open_by_url(all_dk_player_projections)
|
| 94 |
worksheet = sh.worksheet('FD_Stacks')
|