File size: 1,792 Bytes
8a61a98
 
 
596e747
16f32ec
8a61a98
 
16f32ec
 
8a61a98
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import streamlit as st, pandas as pd, random, plotly.graph_objects as go, plotly.express as px
states, top_n = ["Minnesota", "Florida", "California"], 10
health_conditions = [{"condition": "๐Ÿ’” Heart disease", "emoji": "๐Ÿ’—", "spending": 214.3}, {"condition": "๐Ÿค• Trauma-related disorders", "emoji": "๐Ÿš‘", "spending": 198.6}, {"condition": "๐Ÿฆ€ Cancer", "emoji": "๐ŸŽ—๏ธ", "spending": 171.0}, {"condition": "๐Ÿง  Mental disorders", "emoji": "๐Ÿง˜", "spending": 150.8}, {"condition": "๐Ÿฆด Osteoarthritis and joint disorders", "emoji": "๐Ÿฅ", "spending": 142.4}, {"condition": "๐Ÿ’‰ Diabetes", "emoji": "๐Ÿฉธ", "spending": 107.4}, {"condition": "๐Ÿซ Chronic obstructive pulmonary disease and asthma", "emoji": "๐Ÿซ€", "spending": 91.0}, {"condition": "๐Ÿฉบ Hypertension", "emoji": "๐Ÿ’‰", "spending": 83.9}, {"condition": "๐Ÿ”ฌ Hyperlipidemia", "emoji": "๐Ÿ”ฌ", "spending": 83.9}, {"condition": "๐Ÿฆด Back problems", "emoji": "๐Ÿง", "spending": 67.0}]
df_top_conditions = pd.DataFrame(health_conditions)
total_spending = round(df_top_conditions["spending"].sum(), 1)
def roll(): return [random.randint(1, 10) for _ in range(1000)]
fig_sunburst = go.Figure(go.Sunburst(labels=df_top_conditions["emoji"] + " " + df_top_conditions["condition"], parents=[""] * top_n, values=df_top_conditions["spending"], maxdepth=2))
fig_sunburst.update_layout(title=f"Top {top_n} Health Conditions in {', '.join(states)} by Spending (Total: ${total_spending}B)")
st.plotly_chart(fig_sunburst)
for index, row in df_top_conditions.iterrows():
    frequencies = roll()
    fig_bar = px.bar(x=[f"Variant {i}" for i in range(1, 11)], y=frequencies, labels={'x': 'Variant', 'y': 'Frequency'})
    fig_bar.update_layout(title=f"Variants of {row['condition']} ({row['emoji']})")
    st.plotly_chart(fig_bar)