Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -25,6 +25,9 @@ health_conditions = [
|
|
25 |
# Create a DataFrame from the list dictionary
|
26 |
df_top_conditions = pd.DataFrame(health_conditions)
|
27 |
|
|
|
|
|
|
|
28 |
# Define the reroll function
|
29 |
def reroll():
|
30 |
# Randomly select a health condition from the top 10
|
@@ -39,11 +42,17 @@ def reroll():
|
|
39 |
if reroll:
|
40 |
reroll()
|
41 |
|
42 |
-
#
|
43 |
-
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
|
46 |
-
#
|
47 |
-
|
48 |
-
|
49 |
-
yaxis_title="Spending ($B)", plot_bgcolor='rgba(0,0
|
|
|
25 |
# Create a DataFrame from the list dictionary
|
26 |
df_top_conditions = pd.DataFrame(health_conditions)
|
27 |
|
28 |
+
# Calculate the total spending
|
29 |
+
total_spending = round(df_top_conditions["spending"].sum(), 1)
|
30 |
+
|
31 |
# Define the reroll function
|
32 |
def reroll():
|
33 |
# Randomly select a health condition from the top 10
|
|
|
42 |
if reroll:
|
43 |
reroll()
|
44 |
|
45 |
+
# Define the sunburst chart
|
46 |
+
fig_sunburst = go.Figure(go.Sunburst(
|
47 |
+
labels=df_top_conditions["emoji"] + " " + df_top_conditions["condition"],
|
48 |
+
parents=[""] * top_n,
|
49 |
+
values=df_top_conditions["spending"],
|
50 |
+
maxdepth=2
|
51 |
+
))
|
52 |
+
|
53 |
+
# Customize the layout of the sunburst chart
|
54 |
+
fig_sunburst.update_layout(title=f"Top {top_n} Health Conditions in {', '.join(states)} by Spending (Total: ${total_spending}B)")
|
55 |
|
56 |
+
# Display the sunburst chart and reroll button in the Streamlit app
|
57 |
+
st.plotly_chart(fig_sunburst)
|
58 |
+
st.button("Reroll", on_click=reroll)
|
|