awacke1 commited on
Commit
049f923
·
1 Parent(s): 40ed27a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -17
app.py CHANGED
@@ -6,27 +6,67 @@ import pandas as pd
6
  states = ["Minnesota 🌲", "Florida 🌴", "California 🌞"]
7
  top_n = 10
8
 
9
- # Define the list dictionary of top 10 health conditions descending by cost with emojis
10
  health_conditions = [
11
- {"condition": "Heart disease ❤️", "spending": 214.3},
12
- {"condition": "Trauma-related disorders 🤕", "spending": 198.6},
13
- {"condition": "Cancer 🦀", "spending": 171.0},
14
- {"condition": "Mental disorders 🧠", "spending": 150.8},
15
- {"condition": "Osteoarthritis and joint disorders 🦴", "spending": 142.4},
16
- {"condition": "Diabetes 🍬", "spending": 107.4},
17
- {"condition": "Chronic obstructive pulmonary disease and asthma 🫁", "spending": 91.0},
18
- {"condition": "Hypertension 🩺", "spending": 83.9},
19
- {"condition": "Hyperlipidemia 🍔", "spending": 83.9},
20
- {"condition": "Back problems 👨‍⚕️", "spending": 67.0}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  ]
22
 
23
- # Total the spending values
24
  total_spending = sum([hc["spending"] for hc in health_conditions])
25
 
26
- # Create a DataFrame from the list dictionary
27
  df_top_conditions = pd.DataFrame(health_conditions)
28
 
29
- # Create a new field showing the state with the most cases per year for each condition
30
  df_top_conditions['most_cases_state'] = ''
31
  for i, row in df_top_conditions.iterrows():
32
  condition = row['condition'].split(' ')[0]
@@ -35,11 +75,17 @@ for i, row in df_top_conditions.iterrows():
35
  most_cases_state = condition_df.groupby('state')['cases'].sum().idxmax()
36
  df_top_conditions.at[i, 'most_cases_state'] = f'{most_cases_state} 🏆'
37
 
38
- # Create the treemap graph using Plotly Express
39
  fig = px.treemap(df_top_conditions, path=["condition"], values="spending", color='most_cases_state')
40
 
41
- # Set the title of the graph
42
  fig.update_layout(title=f"Top {top_n} Health Conditions in {', '.join(states)} by Spending (Total: ${total_spending}B)")
43
 
44
- # Display the graph in Streamlit
45
  st.plotly_chart(fig)
 
 
 
 
 
 
 
6
  states = ["Minnesota 🌲", "Florida 🌴", "California 🌞"]
7
  top_n = 10
8
 
9
+ # Define the list dictionary of top 10 health conditions descending by cost with emojis and Wikipedia links
10
  health_conditions = [
11
+ {
12
+ "condition": "Heart disease ❤️",
13
+ "spending": 214.3,
14
+ "definition": "Heart disease is when your heart has problems working properly. It can cause chest pain and other symptoms. Learn more at [Wikipedia](https://en.wikipedia.org/wiki/Heart_disease)."
15
+ },
16
+ {
17
+ "condition": "Trauma-related disorders 🤕",
18
+ "spending": 198.6,
19
+ "definition": "Trauma-related disorders are mental health conditions that can occur after someone experiences a traumatic event, like a car accident or natural disaster. Learn more at [Wikipedia](https://en.wikipedia.org/wiki/Trauma_(medicine))."
20
+ },
21
+ {
22
+ "condition": "Cancer 🦀",
23
+ "spending": 171.0,
24
+ "definition": "Cancer is a disease where your body's cells grow out of control. It can cause lumps or tumors and make you feel sick. Learn more at [Wikipedia](https://en.wikipedia.org/wiki/Cancer)."
25
+ },
26
+ {
27
+ "condition": "Mental disorders 🧠",
28
+ "spending": 150.8,
29
+ "definition": "Mental disorders are conditions that affect your mood, behavior, or thinking. They can make it hard to function normally. Learn more at [Wikipedia](https://en.wikipedia.org/wiki/Mental_disorder)."
30
+ },
31
+ {
32
+ "condition": "Osteoarthritis and joint disorders 🦴",
33
+ "spending": 142.4,
34
+ "definition": "Osteoarthritis and joint disorders are conditions that can cause pain and stiffness in your joints. They often happen as you get older. Learn more at [Wikipedia](https://en.wikipedia.org/wiki/Osteoarthritis)."
35
+ },
36
+ {
37
+ "condition": "Diabetes 🍬",
38
+ "spending": 107.4,
39
+ "definition": "Diabetes is a condition where your body has trouble processing sugar. It can cause high blood sugar levels and make you feel sick. Learn more at [Wikipedia](https://en.wikipedia.org/wiki/Diabetes)."
40
+ },
41
+ {
42
+ "condition": "Chronic obstructive pulmonary disease and asthma 🫁",
43
+ "spending": 91.0,
44
+ "definition": "Chronic obstructive pulmonary disease (COPD) and asthma are conditions that can make it hard to breathe. They can cause coughing, wheezing, and other symptoms. Learn more at [Wikipedia](https://en.wikipedia.org/wiki/Chronic_obstructive_pulmonary_disease)."
45
+ },
46
+ {
47
+ "condition": "Hypertension 🩺",
48
+ "spending": 83.9,
49
+ "definition": "Hypertension is another word for high blood pressure. It can put you at risk for heart disease and other health problems. Learn more at [Wikipedia](https://en.wikipedia.org/wiki/Hypertension).
50
+ },
51
+ {
52
+ "condition": "Hyperlipidemia 🍔",
53
+ "spending": 83.9,
54
+ "definition": "Hyperlipidemia is a condition where you have high levels of fat in your blood. It can put you at risk for heart disease and other health problems. Learn more at [Wikipedia](https://en.wikipedia.org/wiki/Hyperlipidemia)."
55
+ },
56
+ {
57
+ "condition": "Back problems 👨‍⚕️",
58
+ "spending": 67.0,
59
+ "definition": "Back problems can cause pain and stiffness in your back. They can be caused by a variety of factors, like poor posture or injuries. Learn more at [Wikipedia](https://en.wikipedia.org/wiki/Back_pain)."
60
+ }
61
  ]
62
 
63
+ #Total the spending values
64
  total_spending = sum([hc["spending"] for hc in health_conditions])
65
 
66
+ #Create a DataFrame from the list dictionary
67
  df_top_conditions = pd.DataFrame(health_conditions)
68
 
69
+ #Create a new field showing the state with the most cases per year for each condition
70
  df_top_conditions['most_cases_state'] = ''
71
  for i, row in df_top_conditions.iterrows():
72
  condition = row['condition'].split(' ')[0]
 
75
  most_cases_state = condition_df.groupby('state')['cases'].sum().idxmax()
76
  df_top_conditions.at[i, 'most_cases_state'] = f'{most_cases_state} 🏆'
77
 
78
+ #Create the treemap graph using Plotly Express
79
  fig = px.treemap(df_top_conditions, path=["condition"], values="spending", color='most_cases_state')
80
 
81
+ #Set the title of the graph
82
  fig.update_layout(title=f"Top {top_n} Health Conditions in {', '.join(states)} by Spending (Total: ${total_spending}B)")
83
 
84
+ #Display the graph in Streamlit
85
  st.plotly_chart(fig)
86
+
87
+ #Display definitions of each condition
88
+ st.markdown("## Condition Definitions")
89
+ for hc in health_conditions:
90
+ st.markdown(f"### {hc['condition']}")
91
+ st.markdown(hc['definition'])