HealthConditionsTest / backupapp.py
awacke1's picture
Create backupapp.py
d21eb79
raw
history blame
1.41 kB
import streamlit as st
import plotly.express as px
import pandas as pd
# Define the states and conditions of interest
states = ["Minnesota", "Florida", "California"]
top_n = 10
# Define the list dictionary of top 10 health conditions descending by cost
health_conditions = [
{"condition": "Heart disease", "spending": 214.3},
{"condition": "Trauma-related disorders", "spending": 198.6},
{"condition": "Cancer", "spending": 171.0},
{"condition": "Mental disorders", "spending": 150.8},
{"condition": "Osteoarthritis and joint disorders", "spending": 142.4},
{"condition": "Diabetes", "spending": 107.4},
{"condition": "Chronic obstructive pulmonary disease and asthma", "spending": 91.0},
{"condition": "Hypertension", "spending": 83.9},
{"condition": "Hyperlipidemia", "spending": 83.9},
{"condition": "Back problems", "spending": 67.0}
]
# Total the spending values
total_spending = sum([hc["spending"] for hc in health_conditions])
# Create a DataFrame from the list dictionary
df_top_conditions = pd.DataFrame(health_conditions)
# Create the treemap graph using Plotly Express
fig = px.treemap(df_top_conditions, path=["condition"], values="spending")
# Set the title of the graph
fig.update_layout(title=f"Top {top_n} Health Conditions in {', '.join(states)} by Spending (Total: ${total_spending}B)")
# Display the graph in Streamlit
st.plotly_chart(fig)