alperugurcan commited on
Commit
d58613e
1 Parent(s): 8bfd4bf

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -0
app.py ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import plotly.express as px
4
+ import plotly.graph_objects as go
5
+
6
+ # Load the dataset
7
+ @st.cache_data
8
+ def load_data():
9
+ df = pd.read_csv('Human Development Index - Full.csv')
10
+ # ... (data preprocessing steps)
11
+ return df_hdi_sorted, df_years, df_rank, df_hdi_groups
12
+
13
+ df_hdi_sorted, df_years, df_rank, df_hdi_groups = load_data()
14
+
15
+ # Streamlit app
16
+ st.title('Human Development Index Analysis')
17
+
18
+ # Sidebar
19
+ st.sidebar.header('Visualization Options')
20
+ chart_type = st.sidebar.selectbox('Select Chart Type',
21
+ ['Top 10 Countries', 'HDI Groups Distribution', 'HDI Trends', 'Bottom 10 Countries',
22
+ 'HDI Improvement', 'HDI Distribution', 'World Map', 'HDI Comparison',
23
+ 'HDI by Development Groups', 'HDI Sunburst'])
24
+
25
+ # Main content
26
+ if chart_type == 'Top 10 Countries':
27
+ st.subheader('Top 10 Countries by HDI (2021)')
28
+ fig = px.bar(df_years.head(10), x='Country', y='Human Development Index (2021)',
29
+ color='Human Development Index (2021)', color_continuous_scale='Viridis')
30
+ st.plotly_chart(fig)
31
+
32
+ elif chart_type == 'HDI Groups Distribution':
33
+ st.subheader('Distribution of Countries by HDI Groups')
34
+ fig = px.pie(df_hdi_groups, names='Human Development Groups')
35
+ st.plotly_chart(fig)
36
+
37
+ # ... (add other chart options)
38
+
39
+ elif chart_type == 'HDI Sunburst':
40
+ st.subheader('HDI Distribution by Groups and Top Countries (2021)')
41
+ df_sunburst = df_hdi_sorted.copy()
42
+ df_sunburst['HDI_2021'] = pd.cut(df_sunburst['Human Development Index (2021)'],
43
+ bins=[0, 0.55, 0.7, 0.8, 1],
44
+ labels=['Low', 'Medium', 'High', 'Very High'])
45
+ fig = px.sunburst(df_sunburst,
46
+ path=['HDI_2021', 'Human Development Groups', 'Country'],
47
+ values='Human Development Index (2021)',
48
+ color='HDI_2021',
49
+ color_discrete_map={'Low': 'red', 'Medium': 'orange',
50
+ 'High': 'lightgreen', 'Very High': 'darkgreen'})
51
+ fig.update_traces(textinfo="label+percent entry")
52
+ st.plotly_chart(fig)
53
+
54
+ # Add more information or text as needed
55
+ st.markdown("""
56
+ This app provides various visualizations of the Human Development Index (HDI) data.
57
+ Use the sidebar to select different chart types and explore the data.
58
+ """)