awacke1 commited on
Commit
a3a53d2
·
1 Parent(s): 93f925a

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +23 -0
app.py ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ # Filter the data by the selected states and get the top n conditions
13
+ df_filtered = df[df["state"].isin(states)]
14
+ df_top_conditions = df_filtered.groupby("condition")["count"].sum().nlargest(top_n)
15
+
16
+ # Create the treemap graph using Plotly Express
17
+ fig = px.treemap(df_top_conditions, path=["condition"], values="count")
18
+
19
+ # Set the title of the graph
20
+ fig.update_layout(title="Top 10 Health Conditions in {} by Count".format(", ".join(states)))
21
+
22
+ # Display the graph in Streamlit
23
+ st.plotly_chart(fig)