File size: 739 Bytes
a3a53d2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import streamlit as st
import plotly.express as px
import pandas as pd

# Load the data
df = pd.read_csv("health_conditions_data.csv")

# Define the states and conditions of interest
states = ["Minnesota", "Florida", "California"]
top_n = 10

# Filter the data by the selected states and get the top n conditions
df_filtered = df[df["state"].isin(states)]
df_top_conditions = df_filtered.groupby("condition")["count"].sum().nlargest(top_n)

# Create the treemap graph using Plotly Express
fig = px.treemap(df_top_conditions, path=["condition"], values="count")

# Set the title of the graph
fig.update_layout(title="Top 10 Health Conditions in {} by Count".format(", ".join(states)))

# Display the graph in Streamlit
st.plotly_chart(fig)