Spaces:
Runtime error
Runtime error
File size: 2,438 Bytes
34929af 0d3b956 a3a53d2 0d3b956 a3a53d2 0d3b956 e3887ab 6cb3226 0d3b956 e3887ab 0d3b956 e3887ab 0d3b956 a3a53d2 0d3b956 40ed27a 0d3b956 a3a53d2 0d3b956 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
import pandas as pd
import streamlit as st
from graphviz import Digraph
st.set_page_config(page_title="Ideal Care Plan for Top 10 Health Conditions")
# Create a pandas dataframe for the top 10 health conditions and their spending
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},
]
df = pd.DataFrame(health_conditions)
# Create Graphviz graph object
graph = Digraph(comment="Ideal Care Plan for Top 10 Health Conditions")
graph.graph_attr["rankdir"] = "LR" # left to right layout
# Add nodes to the graph for each health condition
for i, row in df.iterrows():
condition = row["condition"]
spending = row["spending"]
# Add node to the graph with hyperlink based on condition
if i < 3:
url = f"https://www.cdc.gov/{condition.split()[0].lower()}"
else:
url = None
graph.node(condition, f"{condition}\n${spending:.1f}B", href=url)
# Add edges to the graph based on related conditions
graph.edge("Heart disease ❤️", "Hypertension 🩺")
graph.edge("Heart disease ❤️", "Hyperlipidemia 🍔")
graph.edge("Trauma-related disorders 🤕", "Mental disorders 🧠")
graph.edge("Cancer 🦀", "Heart disease ❤️")
graph.edge("Cancer 🦀", "Trauma-related disorders 🤕")
graph.edge("Cancer 🦀", "Osteoarthritis and joint disorders 🦴")
graph.edge("Mental disorders 🧠", "Heart disease ❤️")
graph.edge("Mental disorders 🧠", "Trauma-related disorders 🤕")
graph.edge("Osteoarthritis and joint disorders 🦴", "Back problems 👨⚕️")
graph.edge("Diabetes 🍬", "Heart disease ❤️")
graph.edge("Diabetes 🍬", "Hypertension 🩺")
graph.edge("Chronic obstructive pulmonary disease and asthma 🫁", "Heart disease ❤️")
# Render the graph as an image and display in Streamlit app
st.graphviz_chart(graph.pipe(format="svg"))
|