awacke1 commited on
Commit
64b053f
ยท
1 Parent(s): 98a1667

Create backupapp.py

Browse files
Files changed (1) hide show
  1. backupapp.py +56 -0
backupapp.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import random
4
+ import plotly.graph_objects as go
5
+ import plotly.express as px
6
+
7
+ # Define the states and conditions of interest
8
+ states = ["Minnesota", "Florida", "California"]
9
+ top_n = 10
10
+
11
+ # Define the list dictionary of top 10 health conditions descending by cost, with emojis
12
+ health_conditions = [
13
+ {"condition": "๐Ÿ’” Heart disease", "emoji": "๐Ÿ’—", "spending": 214.3},
14
+ {"condition": "๐Ÿค• Trauma-related disorders", "emoji": "๐Ÿš‘", "spending": 198.6},
15
+ {"condition": "๐Ÿฆ€ Cancer", "emoji": "๐ŸŽ—๏ธ", "spending": 171.0},
16
+ {"condition": "๐Ÿง  Mental disorders", "emoji": "๐Ÿง˜", "spending": 150.8},
17
+ {"condition": "๐Ÿฆด Osteoarthritis and joint disorders", "emoji": "๐Ÿฅ", "spending": 142.4},
18
+ {"condition": "๐Ÿ’‰ Diabetes", "emoji": "๐Ÿฉธ", "spending": 107.4},
19
+ {"condition": "๐Ÿซ Chronic obstructive pulmonary disease and asthma", "emoji": "๐Ÿซ€", "spending": 91.0},
20
+ {"condition": "๐Ÿฉบ Hypertension", "emoji": "๐Ÿ’‰", "spending": 83.9},
21
+ {"condition": "๐Ÿ”ฌ Hyperlipidemia", "emoji": "๐Ÿ”ฌ", "spending": 83.9},
22
+ {"condition": "๐Ÿฆด Back problems", "emoji": "๐Ÿง", "spending": 67.0}
23
+ ]
24
+
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 roll function
32
+ def roll():
33
+ # Generate a thousand 10-sided dice rolls for each health condition
34
+ rolls = [random.randint(1, 10) for _ in range(1000)]
35
+ # Calculate the frequency of each variant
36
+ frequencies = [rolls.count(i) for i in range(1, 11)]
37
+ return frequencies
38
+
39
+ # Define the sunburst chart
40
+ fig_sunburst = go.Figure(go.Sunburst(
41
+ labels=df_top_conditions["emoji"] + " " + df_top_conditions["condition"],
42
+ parents=[""] * top_n,
43
+ values=df_top_conditions["spending"],
44
+ maxdepth=2
45
+ ))
46
+
47
+ # Customize the layout of the sunburst chart
48
+ fig_sunburst.update_layout(title=f"Top {top_n} Health Conditions in {', '.join(states)} by Spending (Total: ${total_spending}B)")
49
+
50
+ # Display the sunburst chart and variants per condition in the Streamlit app
51
+ st.plotly_chart(fig_sunburst)
52
+ for index, row in df_top_conditions.iterrows():
53
+ frequencies = roll()
54
+ fig_bar = px.bar(x=[f"Variant {i}" for i in range(1, 11)], y=frequencies[:10], labels={'x': 'Variant', 'y': 'Frequency'})
55
+ fig_bar.update_layout(title=f"Variants of {row['condition']} ({row['emoji']})")
56
+ st.plotly_chart(fig_bar)