Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,109 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
import graphviz as gv
|
3 |
+
from graphviz import Graph
|
4 |
+
import folium
|
5 |
+
from streamlit_folium import folium_static
|
6 |
+
import pandas as pd
|
7 |
+
import matplotlib.pyplot as plt
|
8 |
+
import altair as alt
|
9 |
+
|
10 |
+
# Define the top 10 mental health facilities by bed size in the US
|
11 |
+
hospitals = [('McLean Hospital', 'Belmont, MA', 182),
|
12 |
+
('Menninger Clinic', 'Houston, TX', 164),
|
13 |
+
('Johns Hopkins Hospital', 'Baltimore, MD', 119),
|
14 |
+
('Sheppard Pratt Hospital', 'Towson, MD', 118),
|
15 |
+
('New York-Presbyterian Hospital', 'New York, NY', 117),
|
16 |
+
('Austen Riggs Center', 'Stockbridge, MA', 70),
|
17 |
+
('Butler Hospital', 'Providence, RI', 68),
|
18 |
+
('Rogers Memorial Hospital', 'Oconomowoc, WI', 67),
|
19 |
+
('Silver Hill Hospital', 'New Canaan, CT', 54),
|
20 |
+
('Spectrum Health Hospitals Butterworth Hospital', 'Grand Rapids, MI', 53)]
|
21 |
+
|
22 |
+
# Create a Graphviz chart of the hospitals
|
23 |
+
g = Graph(format='svg')
|
24 |
+
g.graph_attr['bgcolor'] = '#FFFFFF'
|
25 |
+
g.graph_attr['outputorder'] = 'edgesfirst'
|
26 |
+
g.graph_attr['size'] = '10,10'
|
27 |
+
g.node_attr['style'] = 'filled'
|
28 |
+
g.node_attr['shape'] = 'box'
|
29 |
+
g.node_attr['fillcolor'] = '#FFDAB9'
|
30 |
+
|
31 |
+
with g.subgraph(name='cluster_US') as c:
|
32 |
+
c.graph_attr['bgcolor'] = '#ADD8E6'
|
33 |
+
c.node_attr['color'] = '#000000'
|
34 |
+
c.node_attr['fontcolor'] = '#000000'
|
35 |
+
c.attr(label='Top 10 Mental Health Facilities by Bed Size in the US', fontsize='24')
|
36 |
+
for hospital in hospitals:
|
37 |
+
c.node(f"{hospital[0]}\n{hospital[1]}\n{hospital[2]} beds")
|
38 |
+
|
39 |
+
# Render the Graphviz chart in Streamlit
|
40 |
+
st.graphviz_chart(g)
|
41 |
+
|
42 |
+
# Create a Folium map of the hospitals
|
43 |
+
m = folium.Map(location=[39.5, -98.35], zoom_start=4)
|
44 |
+
|
45 |
+
for hospital in hospitals:
|
46 |
+
folium.Marker(
|
47 |
+
location=[hospital[1].split(', ')[0], hospital[1].split(', ')[1]],
|
48 |
+
popup=f"{hospital[0]}\n{hospital[1]}\n{hospital[2]} beds",
|
49 |
+
icon=folium.Icon(color='red', icon='info-sign')
|
50 |
+
).add_to(m)
|
51 |
+
|
52 |
+
# Display the Folium map in Streamlit
|
53 |
+
folium_static(m)
|
54 |
+
|
55 |
+
# Create a dataframe of the hospital data
|
56 |
+
df = pd.DataFrame(hospitals, columns=['Hospital', 'Location', 'Bed Size'])
|
57 |
+
|
58 |
+
# Create a Matplotlib chart of the hospital bed sizes
|
59 |
+
fig, ax = plt.subplots()
|
60 |
+
ax.bar(df['Hospital'], df['Bed Size'])
|
61 |
+
ax.set_xticklabels(df['Hospital'], rotation=45)
|
62 |
+
ax.set_xlabel('Hospital')
|
63 |
+
ax.set_ylabel('Bed Size')
|
64 |
+
ax.set_title('Top 10 Mental Health Facilities by Bed Size in the US')
|
65 |
+
st.pyplot(fig)
|
66 |
+
|
67 |
+
# Create an Altair chart of the hospital bed sizes
|
68 |
+
alt_chart = alt.Chart(df).mark_bar().encode(
|
69 |
+
x='Hospital',
|
70 |
+
y='Bed Size'
|
71 |
+
).properties(
|
72 |
+
title='Top 10 Mental Health Facilities by Bed Size in the US'
|
73 |
+
)
|
74 |
+
|
75 |
+
# Display the Altair chart in Streamlit
|
76 |
+
st.altair_chart(alt_chart)
|
77 |
+
|
78 |
+
# Top 20 Mental Health Facilities by Bed Size in the US
|
79 |
+
top_hospitals = [
|
80 |
+
(1, 'McLean Hospital', 'Belmont, MA', 182, 'Known for its treatment of borderline personality disorder.'),
|
81 |
+
(2, 'Menninger Clinic', 'Houston, TX', 164, 'Uses an integrative approach that combines therapy, medication, and other treatments.'),
|
82 |
+
(3, 'Johns Hopkins Hospital', 'Baltimore, MD', 119, 'Specializes in the treatment of mood disorders and addiction.'),
|
83 |
+
(4, 'Sheppard Pratt Hospital', 'Towson, MD', 118, 'Offers a range of specialty programs, including ones for eating disorders and addiction.'),
|
84 |
+
(5, 'New York-Presbyterian Hospital', 'New York, NY', 117, 'One of the largest mental health facilities in the country, with a wide range of treatment options.'),
|
85 |
+
(6, 'Austen Riggs Center', 'Stockbridge, MA', 70, 'Known for its focus on long-term treatment and the importance of relationships.'),
|
86 |
+
(7, 'Butler Hospital', 'Providence, RI', 68, 'Offers a range of specialized programs, including ones for bipolar disorder and addiction.'),
|
87 |
+
(8, 'Rogers Memorial Hospital', 'Oconomowoc, WI', 67, 'Offers a range of specialty programs, including ones for OCD and eating disorders.'),
|
88 |
+
(9, 'Silver Hill Hospital', 'New Canaan, CT', 54, 'Known for its focus on treating co-occurring mental health and addiction issues.'),
|
89 |
+
(10, 'Spectrum Health Hospitals Butterworth Hospital', 'Grand Rapids, MI', 53, 'Offers a range of specialized programs, including ones for PTSD and addiction.'),
|
90 |
+
(11, 'University of Michigan Hospitals-Michigan Medicine', 'Ann Arbor, MI', 49, 'Offers a range of specialized programs, including ones for depression and anxiety.'),
|
91 |
+
(12, 'Vanderbilt University Medical Center', 'Nashville, TN', 48, 'Offers a range of specialized programs, including ones for schizophrenia and bipolar disorder.'),
|
92 |
+
(13, 'Mayo Clinic', 'Rochester, MN', 47, 'Known for its focus on integrated care and a patient-centered approach.'),
|
93 |
+
(14, 'UPMC Western Psychiatric Hospital', 'Pittsburgh, PA', 46, 'Offers a range of specialized programs, including ones for autism and bipolar disorder.'),
|
94 |
+
(15, 'Cleveland Clinic', 'Cleveland, OH', 45, 'Offers a range of specialized programs, including ones for geriatric mental health and addiction.'),
|
95 |
+
(16, 'McLean SouthEast', 'Middleborough, MA', 44, 'Offers a range of specialized programs, including ones for trauma and addiction.'),
|
96 |
+
(17, 'Laurel Ridge Treatment Center', 'San Antonio, TX', 44, 'Offers a range of specialized programs, including ones for PTSD and addiction.'),
|
97 |
+
(18, 'Mercy Hospital', 'Chicago, IL', 42, 'Offers a range of specialized programs, including ones for geriatric mental health and addiction.'),
|
98 |
+
(19, 'University of Iowa Hospitals and Clinics', 'Iowa City, IA', 42, 'Offers a range of specialized programs, including ones for eating disorders and addiction.'),
|
99 |
+
(20, 'Rogers Behavioral Health', 'Oconomowoc, WI', 41, 'Offers a range of specialized programs, including ones for OCD and addiction.')
|
100 |
+
]
|
101 |
+
|
102 |
+
table = "| Rank | Hospital | Location | Bed Size | Unique Care |\n"
|
103 |
+
table += "| --- | --- | --- | --- | --- |\n"
|
104 |
+
for hospital in top_hospitals:
|
105 |
+
table += f"| {hospital[0]} | {hospital[1]} | {hospital[2]} | {hospital[3]} beds | {hospital[4]} |\n"
|
106 |
+
st.markdown("## Top 20 Mental Health Facilities by Bed Size in the US")
|
107 |
+
st.markdown(table)
|
108 |
+
|
109 |
+
|