Spaces:
Running
Running
File size: 2,756 Bytes
c1d6516 0917471 c1d6516 3d00450 c1d6516 3d00450 c1d6516 3d00450 0917471 57c489b 5faa553 0917471 21dca8d c1d6516 d117a25 3d00450 0917471 e54a8b1 0917471 e54a8b1 d117a25 0917471 3d00450 d117a25 0917471 e54a8b1 d117a25 e54a8b1 24e9e65 0917471 24e9e65 e54a8b1 24e9e65 792293e 24e9e65 0917471 3d00450 |
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 |
import streamlit as st
st.set_page_config(layout="wide")
for name in dir():
if not name.startswith('_'):
del globals()[name]
import numpy as np
import pandas as pd
import streamlit as st
import gc
import pymongo
@st.cache_resource
def init_conn():
uri = st.secrets['mongo_uri']
client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=500000)
db = client["PGA_Database"]
return db
db = init_conn()
dk_player_url = 'https://docs.google.com/spreadsheets/d/1lMLxWdvCnOFBtG9dhM0zv2USuxZbkogI_2jnxFfQVVs/edit#gid=1828092624'
CSV_URL = 'https://docs.google.com/spreadsheets/d/1lMLxWdvCnOFBtG9dhM0zv2USuxZbkogI_2jnxFfQVVs/edit#gid=1828092624'
player_roo_format = {'Top_finish': '{:.2%}','Top_5_finish': '{:.2%}', 'Top_10_finish': '{:.2%}', '100+%': '{:.2%}', '10x%': '{:.2%}', '11x%': '{:.2%}',
'12x%': '{:.2%}','LevX': '{:.2%}'}
@st.cache_resource(ttl = 600)
def init_baselines():
collection = db["PGA_Range_of_Outcomes"]
cursor = collection.find()
player_frame = pd.DataFrame(cursor)
timestamp = player_frame['Timestamp'][0]
roo_data = player_frame.drop(columns=['_id', 'index', 'Timestamp'])
roo_data['Salary'] = roo_data['Salary'].astype(int)
return roo_data, timestamp
def convert_df_to_csv(df):
return df.to_csv().encode('utf-8')
roo_data, timestamp = init_baselines()
hold_display = roo_data
lineup_display = []
check_list = []
rand_player = 0
boost_player = 0
salaryCut = 0
tab1, tab2 = st.tabs(["Player Overall Projections", "Not Ready Yet"])
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_data, timestamp = init_baselines()
hold_display = roo_data
lineup_display = []
check_list = []
rand_player = 0
boost_player = 0
salaryCut = 0
st.write(timestamp)
options_container = st.empty()
hold_container = st.empty()
with options_container:
site_var = st.selectbox("Select a Site", ["Draftkings", "FanDuel"])
with hold_container:
display = hold_display[hold_display['Site'] == site_var]
st.dataframe(display.style.background_gradient(axis=0).background_gradient(cmap='RdYlGn').format(player_roo_format, precision=2), height=750, use_container_width = True)
st.download_button(
label="Export Projections",
data=convert_df_to_csv(display),
file_name='PGA_DFS_export.csv',
mime='text/csv',
)
with tab2:
st.write("Not Ready Yet") |