hhalim's picture
Create app.py
7ce6ae9
raw
history blame
1.51 kB
import plotly.graph_objects as go
import streamlit as st
import pandas as pd
from transformers import AutoModelWithLMHead
# Create a list of the top five largest hospitals in the state of Minnesota
hospitals_dict = [
{'name': 'Mayo Clinic',
'number_beds': 1569,
'latitude': 44.074,
'longitude': -92.4591},
{'name': 'United Hospital',
'number_beds': 663,
'latitude': 44.8794,
'longitude': -93.1748},
{'name': 'Allina Health',
'number_beds': 600,
'latitude': 44.9352,
'longitude': -93.0614},
{'name': 'Fairview Southdale Hospital',
'number_beds': 446,
'latitude': 44.8552,
'longitude': -93.3455},
{'name': 'St. Cloud Hospital',
'number_beds': 437,
'latitude': 45.5517,
'longitude': -94.1613}
]
# Create the dataframe from the list of dictionaries
df = pd.DataFrame(hospitals_dict)
# Create a treemap with plotly graph objects
fig = go.Figure(data=go.Treemap(
labels=df['name'],
parents=['Minnesota'] * len(df),
values=df['number_beds'],
))
# Create the Huggingface model
model = AutoModelWithLMHead.from_pretrained("distilbert-base-uncased")
# Streamlit app
st.title("Minnesota's Largest Hospitals")
# Display the treemap
st.plotly_chart(fig)
# Display hospital information
st.subheader("Hospital Information")
st.write(df)
# Save the dataframe as a CSV file
st.subheader("Save CSV File")
st.markdown("Click the button below to save the dataframe as a CSV file.")
st.write(df.to_csv(index=False))