Spaces:
Runtime error
Runtime error
import streamlit as st | |
import graphviz as gv | |
from graphviz import Graph | |
import folium | |
from streamlit_folium import folium_static | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
import altair as alt | |
# Define the top 10 mental health facilities by bed size in the US | |
hospitals = [('McLean Hospital', 'Belmont, MA', 182), | |
('Menninger Clinic', 'Houston, TX', 164), | |
('Johns Hopkins Hospital', 'Baltimore, MD', 119), | |
('Sheppard Pratt Hospital', 'Towson, MD', 118), | |
('New York-Presbyterian Hospital', 'New York, NY', 117), | |
('Austen Riggs Center', 'Stockbridge, MA', 70), | |
('Butler Hospital', 'Providence, RI', 68), | |
('Rogers Memorial Hospital', 'Oconomowoc, WI', 67), | |
('Silver Hill Hospital', 'New Canaan, CT', 54), | |
('Spectrum Health Hospitals Butterworth Hospital', 'Grand Rapids, MI', 53)] | |
# Create a Graphviz chart of the hospitals | |
g = Graph(format='svg') | |
g.graph_attr['bgcolor'] = '#FFFFFF' | |
g.graph_attr['outputorder'] = 'edgesfirst' | |
g.graph_attr['size'] = '10,10' | |
g.node_attr['style'] = 'filled' | |
g.node_attr['shape'] = 'box' | |
g.node_attr['fillcolor'] = '#FFDAB9' | |
with g.subgraph(name='cluster_US') as c: | |
c.graph_attr['bgcolor'] = '#ADD8E6' | |
c.node_attr['color'] = '#000000' | |
c.node_attr['fontcolor'] = '#000000' | |
c.attr(label='Top 10 Mental Health Facilities by Bed Size in the US', fontsize='24') | |
for hospital in hospitals: | |
c.node(f"{hospital[0]}\n{hospital[1]}\n{hospital[2]} beds") | |
# Render the Graphviz chart in Streamlit | |
st.graphviz_chart(g) | |
# Create a Folium map of the hospitals | |
#m = folium.Map(location=[39.5, -98.35], zoom_start=4) | |
#for hospital in hospitals: | |
# folium.Marker( | |
# location=[hospital[1].split(', ')[0], hospital[1].split(', ')[1]], | |
# popup=f"{hospital[0]}\n{hospital[1]}\n{hospital[2]} beds", | |
# icon=folium.Icon(color='red', icon='info-sign') | |
# ).add_to(m) | |
# Display the Folium map in Streamlit | |
#folium_static(m) | |
# Create a dataframe of the hospital data | |
df = pd.DataFrame(hospitals, columns=['Hospital', 'Location', 'Bed Size']) | |
# Create a Matplotlib chart of the hospital bed sizes | |
fig, ax = plt.subplots() | |
ax.bar(df['Hospital'], df['Bed Size']) | |
ax.set_xticklabels(df['Hospital'], rotation=45) | |
ax.set_xlabel('Hospital') | |
ax.set_ylabel('Bed Size') | |
ax.set_title('Top 10 Mental Health Facilities by Bed Size in the US') | |
st.pyplot(fig) | |
# Create an Altair chart of the hospital bed sizes | |
alt_chart = alt.Chart(df).mark_bar().encode( | |
x='Hospital', | |
y='Bed Size' | |
).properties( | |
title='Top 10 Mental Health Facilities by Bed Size in the US' | |
) | |
# Display the Altair chart in Streamlit | |
st.altair_chart(alt_chart) | |
# Top 20 Mental Health Facilities by Bed Size in the US | |
top_hospitals = [ | |
(1, 'McLean Hospital', 'Belmont, MA', 182, 'Known for its treatment of borderline personality disorder.'), | |
(2, 'Menninger Clinic', 'Houston, TX', 164, 'Uses an integrative approach that combines therapy, medication, and other treatments.'), | |
(3, 'Johns Hopkins Hospital', 'Baltimore, MD', 119, 'Specializes in the treatment of mood disorders and addiction.'), | |
(4, 'Sheppard Pratt Hospital', 'Towson, MD', 118, 'Offers a range of specialty programs, including ones for eating disorders and addiction.'), | |
(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.'), | |
(6, 'Austen Riggs Center', 'Stockbridge, MA', 70, 'Known for its focus on long-term treatment and the importance of relationships.'), | |
(7, 'Butler Hospital', 'Providence, RI', 68, 'Offers a range of specialized programs, including ones for bipolar disorder and addiction.'), | |
(8, 'Rogers Memorial Hospital', 'Oconomowoc, WI', 67, 'Offers a range of specialty programs, including ones for OCD and eating disorders.'), | |
(9, 'Silver Hill Hospital', 'New Canaan, CT', 54, 'Known for its focus on treating co-occurring mental health and addiction issues.'), | |
(10, 'Spectrum Health Hospitals Butterworth Hospital', 'Grand Rapids, MI', 53, 'Offers a range of specialized programs, including ones for PTSD and addiction.'), | |
(11, 'University of Michigan Hospitals-Michigan Medicine', 'Ann Arbor, MI', 49, 'Offers a range of specialized programs, including ones for depression and anxiety.'), | |
(12, 'Vanderbilt University Medical Center', 'Nashville, TN', 48, 'Offers a range of specialized programs, including ones for schizophrenia and bipolar disorder.'), | |
(13, 'Mayo Clinic', 'Rochester, MN', 47, 'Known for its focus on integrated care and a patient-centered approach.'), | |
(14, 'UPMC Western Psychiatric Hospital', 'Pittsburgh, PA', 46, 'Offers a range of specialized programs, including ones for autism and bipolar disorder.'), | |
(15, 'Cleveland Clinic', 'Cleveland, OH', 45, 'Offers a range of specialized programs, including ones for geriatric mental health and addiction.'), | |
(16, 'McLean SouthEast', 'Middleborough, MA', 44, 'Offers a range of specialized programs, including ones for trauma and addiction.'), | |
(17, 'Laurel Ridge Treatment Center', 'San Antonio, TX', 44, 'Offers a range of specialized programs, including ones for PTSD and addiction.'), | |
(18, 'Mercy Hospital', 'Chicago, IL', 42, 'Offers a range of specialized programs, including ones for geriatric mental health and addiction.'), | |
(19, 'University of Iowa Hospitals and Clinics', 'Iowa City, IA', 42, 'Offers a range of specialized programs, including ones for eating disorders and addiction.'), | |
(20, 'Rogers Behavioral Health', 'Oconomowoc, WI', 41, 'Offers a range of specialized programs, including ones for OCD and addiction.') | |
] | |
table = "| Rank | Hospital | Location | Bed Size | Unique Care |\n" | |
table += "| --- | --- | --- | --- | --- |\n" | |
for hospital in top_hospitals: | |
table += f"| {hospital[0]} | {hospital[1]} | {hospital[2]} | {hospital[3]} beds | {hospital[4]} |\n" | |
st.markdown("## Top 20 Mental Health Facilities by Bed Size in the US") | |
st.markdown(table) | |