Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import plotly.graph_objects as go
|
2 |
+
import streamlit as st
|
3 |
+
import pandas as pd
|
4 |
+
from transformers import AutoModelWithLMHead
|
5 |
+
|
6 |
+
# Create a list of the top five largest hospitals in the state of Minnesota
|
7 |
+
hospitals_dict = [
|
8 |
+
{'name': 'Mayo Clinic',
|
9 |
+
'number_beds': 1569,
|
10 |
+
'latitude': 44.074,
|
11 |
+
'longitude': -92.4591},
|
12 |
+
{'name': 'United Hospital',
|
13 |
+
'number_beds': 663,
|
14 |
+
'latitude': 44.8794,
|
15 |
+
'longitude': -93.1748},
|
16 |
+
{'name': 'Allina Health',
|
17 |
+
'number_beds': 600,
|
18 |
+
'latitude': 44.9352,
|
19 |
+
'longitude': -93.0614},
|
20 |
+
{'name': 'Fairview Southdale Hospital',
|
21 |
+
'number_beds': 446,
|
22 |
+
'latitude': 44.8552,
|
23 |
+
'longitude': -93.3455},
|
24 |
+
{'name': 'St. Cloud Hospital',
|
25 |
+
'number_beds': 437,
|
26 |
+
'latitude': 45.5517,
|
27 |
+
'longitude': -94.1613}
|
28 |
+
]
|
29 |
+
|
30 |
+
# Create the dataframe from the list of dictionaries
|
31 |
+
df = pd.DataFrame(hospitals_dict)
|
32 |
+
|
33 |
+
# Create a treemap with plotly graph objects
|
34 |
+
fig = go.Figure(data=go.Treemap(
|
35 |
+
labels=df['name'],
|
36 |
+
parents=['Minnesota'] * len(df),
|
37 |
+
values=df['number_beds'],
|
38 |
+
))
|
39 |
+
|
40 |
+
# Create the Huggingface model
|
41 |
+
model = AutoModelWithLMHead.from_pretrained("distilbert-base-uncased")
|
42 |
+
|
43 |
+
# Streamlit app
|
44 |
+
st.title("Minnesota's Largest Hospitals")
|
45 |
+
|
46 |
+
# Display the treemap
|
47 |
+
st.plotly_chart(fig)
|
48 |
+
|
49 |
+
# Display hospital information
|
50 |
+
st.subheader("Hospital Information")
|
51 |
+
st.write(df)
|
52 |
+
|
53 |
+
# Save the dataframe as a CSV file
|
54 |
+
st.subheader("Save CSV File")
|
55 |
+
st.markdown("Click the button below to save the dataframe as a CSV file.")
|
56 |
+
st.write(df.to_csv(index=False))
|