Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,23 +1,35 @@
|
|
1 |
import streamlit as st
|
2 |
import plotly.express as px
|
3 |
-
import pandas as pd
|
4 |
-
|
5 |
-
# Load the data
|
6 |
-
df = pd.read_csv("health_conditions_data.csv")
|
7 |
|
8 |
# Define the states and conditions of interest
|
9 |
states = ["Minnesota", "Florida", "California"]
|
10 |
top_n = 10
|
11 |
|
12 |
-
#
|
13 |
-
|
14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
|
16 |
# Create the treemap graph using Plotly Express
|
17 |
-
fig = px.treemap(df_top_conditions, path=["condition"], values="
|
18 |
|
19 |
# Set the title of the graph
|
20 |
-
fig.update_layout(title="Top
|
21 |
|
22 |
# Display the graph in Streamlit
|
23 |
st.plotly_chart(fig)
|
|
|
1 |
import streamlit as st
|
2 |
import plotly.express as px
|
|
|
|
|
|
|
|
|
3 |
|
4 |
# Define the states and conditions of interest
|
5 |
states = ["Minnesota", "Florida", "California"]
|
6 |
top_n = 10
|
7 |
|
8 |
+
# Define the list dictionary of top 10 health conditions descending by cost
|
9 |
+
health_conditions = [
|
10 |
+
{"condition": "Heart disease", "spending": 214.3},
|
11 |
+
{"condition": "Trauma-related disorders", "spending": 198.6},
|
12 |
+
{"condition": "Cancer", "spending": 171.0},
|
13 |
+
{"condition": "Mental disorders", "spending": 150.8},
|
14 |
+
{"condition": "Osteoarthritis and joint disorders", "spending": 142.4},
|
15 |
+
{"condition": "Diabetes", "spending": 107.4},
|
16 |
+
{"condition": "Chronic obstructive pulmonary disease and asthma", "spending": 91.0},
|
17 |
+
{"condition": "Hypertension", "spending": 83.9},
|
18 |
+
{"condition": "Hyperlipidemia", "spending": 83.9},
|
19 |
+
{"condition": "Back problems", "spending": 67.0}
|
20 |
+
]
|
21 |
+
|
22 |
+
# Total the spending values
|
23 |
+
total_spending = sum([hc["spending"] for hc in health_conditions])
|
24 |
+
|
25 |
+
# Create a DataFrame from the list dictionary
|
26 |
+
df_top_conditions = pd.DataFrame(health_conditions)
|
27 |
|
28 |
# Create the treemap graph using Plotly Express
|
29 |
+
fig = px.treemap(df_top_conditions, path=["condition"], values="spending")
|
30 |
|
31 |
# Set the title of the graph
|
32 |
+
fig.update_layout(title=f"Top {top_n} Health Conditions in {', '.join(states)} by Spending (Total: ${total_spending}B)")
|
33 |
|
34 |
# Display the graph in Streamlit
|
35 |
st.plotly_chart(fig)
|