Spaces:
Running
Running
File size: 805 Bytes
e23665a b92949e 12ff34e e23665a b92949e 12ff34e b92949e 652af3f b92949e |
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 |
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 = 300)
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_duplicates(subset='Player')
return raw_frame
hr_frame = init_baselines()
st.title("HR Finder Table")
st.dataframe(hr_frame, use_container_width = True, hide_index = True) |