Spaces:
Running
Running
File size: 1,087 Bytes
e23665a b92949e 12ff34e e23665a b92949e 12ff34e b92949e 6c12e73 b92949e 6c12e73 b92949e 6c12e73 b92949e d806cb7 6c12e73 |
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 |
import numpy as np
import pandas as pd
import streamlit as st
import pymongo
import os
st.set_page_config(layout="wide")
@st.cache_resource
def init_conn():
uri = os.getenv('mongo_uri')
client = pymongo.MongoClient(uri, retryWrites=True, serverSelectionTimeoutMS=500000)
db = client["MLB_Database"]
return db
db = init_conn()
@st.cache_resource(ttl = 60)
def init_baselines():
collection = db["HR_Table"]
cursor = collection.find()
raw_display = pd.DataFrame(cursor)
raw_display.rename(columns={"Names": "Player"}, inplace = True)
raw_frame = raw_display.drop(columns=['_id']).drop_duplicates(subset='Player')
return raw_frame
hr_frame = init_baselines()
st.title("HR Finder Table")
disp_options = st.radio("Display options:", options = ['Exclude DFS Info', 'Include DFS Info'], key='display_options')
if disp_options == 'Exclude DFS Info':
disp_frame = hr_frame.drop(columns=['Salary', 'Position', 'FD_Position', 'Order'])
else:
disp_frame = hr_frame.copy()
st.dataframe(disp_frame, use_container_width = True, hide_index = True) |