awacke1 commited on
Commit
c94158d
ยท
1 Parent(s): d45b3ad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +50 -0
app.py CHANGED
@@ -73,5 +73,55 @@ def app():
73
  file.write(f'Tip' + ': {tip} {emoji}\nLife points: 10\n')
74
  st.success('Tip submitted!')
75
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76
  if __name__ == '__main__':
77
  app()
 
 
 
 
73
  file.write(f'Tip' + ': {tip} {emoji}\nLife points: 10\n')
74
  st.success('Tip submitted!')
75
 
76
+
77
+ import streamlit as st
78
+ import pandas as pd
79
+ import plotly.graph_objects as go
80
+ import plotly.express as px
81
+
82
+ # Define the states and conditions of interest
83
+ states = ["Minnesota", "Florida", "California", "Washington", "Maine", "Texas"]
84
+ top_n = 10
85
+
86
+ # Define the list dictionary of top 10 health conditions descending by cost, with emojis
87
+ health_conditions = [
88
+ {"condition": "๐Ÿ’” Heart disease", "emoji": "๐Ÿ’—", "spending": 214.3},
89
+ {"condition": "๐Ÿค• Trauma-related disorders", "emoji": "๐Ÿš‘", "spending": 198.6},
90
+ {"condition": "๐Ÿฆ€ Cancer", "emoji": "๐ŸŽ—๏ธ", "spending": 171.0},
91
+ {"condition": "๐Ÿง  Mental disorders", "emoji": "๐Ÿง˜", "spending": 150.8},
92
+ {"condition": "๐Ÿฆด Osteoarthritis and joint disorders", "emoji": "๐Ÿฅ", "spending": 142.4},
93
+ {"condition": "๐Ÿ’‰ Diabetes", "emoji": "๐Ÿฉธ", "spending": 107.4},
94
+ {"condition": "๐Ÿซ Chronic obstructive pulmonary disease and asthma", "emoji": "๐Ÿซ€", "spending": 91.0},
95
+ {"condition": "๐Ÿฉบ Hypertension", "emoji": "๐Ÿ’‰", "spending": 83.9},
96
+ {"condition": "๐Ÿ”ฌ Hyperlipidemia", "emoji": "๐Ÿ”ฌ", "spending": 83.9},
97
+ {"condition": "๐Ÿฆด Back problems", "emoji": "๐Ÿง", "spending": 67.0}
98
+ ]
99
+
100
+ # Total the spending values
101
+ total_spending = sum([hc["spending"] for hc in health_conditions])
102
+
103
+ # Create a DataFrame from the list dictionary
104
+ df_top_conditions = pd.DataFrame(health_conditions)
105
+
106
+ # Create the map graph using Plotly Express
107
+ locations = ["CA", "FL", "MN", "WA", "ME", "TX"]
108
+ fig_map = px.choropleth(locations=locations, locationmode="USA-states", color=[1, 2, 3, 4, 5, 6], scope="usa")
109
+ fig_map.update_layout(geo=dict(bgcolor= "rgba(0, 0, 0, 0)", lakecolor="rgb(255, 255, 255)"))
110
+
111
+ # Create the bar chart using Plotly Graph Objects
112
+ fig_bar = go.Figure(go.Bar(x=df_top_conditions["emoji"] + " " + df_top_conditions["condition"], y=df_top_conditions["spending"], marker_color="#1f77b4"))
113
+ fig_bar.update_layout(title=f"Top {top_n} Health Conditions in {', '.join(states)} by Spending (Total: ${total_spending}B)",
114
+ yaxis_title="Spending ($B)", plot_bgcolor='rgba(0,0,0,0)', xaxis=dict(showgrid=False), yaxis=dict(showgrid=False))
115
+
116
+ # Display the map and the bar chart in Streamlit
117
+ col1, col2 = st.columns([2, 1])
118
+ with col1:
119
+ st.plotly_chart(fig_map, use_container_width=True)
120
+ with col2:
121
+ st.plotly_chart(fig_bar, use_container_width=True)
122
+
123
  if __name__ == '__main__':
124
  app()
125
+
126
+
127
+