Setup
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
import plotly.express as px
import plotly.graph_objects as go
#chart_studio.tools.set_credentials_file(username='econdata777', api_key='ADDhere')
import statsmodels.api as sm
import statsmodels.formula.api as smf
import warnings
#warnings.filterwarnings('ignore')
Import data
df1 = pd.read_csv("https://raw.githubusercontent.com/quarcs-lab/mendez2020-convergence-clubs-code-data/master/assets/dat.csv")
#df1 = pd.read_csv("https://raw.githubusercontent.com/quarcs-lab/mendez2020-convergence-clubs-code-data/master/assets/dat.csv", parse_dates =['year'])
df1
#df1.head()
df1.columns
df1.dtypes
df1['country'].unique()
Dataset definitions
# Import definitions of dataset
df1_def = pd.read_csv("https://raw.githubusercontent.com/quarcs-lab/mendez2020-convergence-clubs-code-data/master//assets/dat-definitions.csv")
df1_def
Descriptive statistics
df1.describe().round(2)
Prepare data
select
df1[df1['region']=='Asia']
query
df1[['country', 'year','s','h','lp','GDPpc']].query("country==['South Korea', 'Thailand','Nepal']")
Visualize data
Overall
The World Population Trend between 1990 and 2014
px.area(df1, x="year", y="pop", color="region", line_group="country")
Year of Schooling
px.choropleth(df1,
color='s',
labels={'s':'Year of Schooling'},
locations='isocode',
animation_frame='year',
hover_name='country')
px.strip(df1,
x = 's',
y = 'region',
hover_name= 'country',
color= 'region',
animation_frame= 'year')
px.line(df1,
x = 'year',
y = 's',
color = 'country',
hover_name='country',
facet_col= 'region',
labels={'s':'Year of Schooling'})
px.box(df1, x = 's', hover_name= 'country',labels={'s':'Year of Schooling'})
px.histogram(df1,
x="s",
color="hi1990",
hover_name= 'country',
marginal='box',
animation_frame = 'year',
labels={'s':'Year of Schooling','hi1990':'developed country?'})
px.scatter(df1,
x="s",
color="region",
size='pop',
hover_name="country",
animation_frame = 'year',
size_max=45,
labels={'s':'Year of Schooling'},
title = "The Relationship between Popolation and Year of Schooling")
Asia
px.line(df1[df1['region']=='Asia'],
x = 'year',
y = 's',
color = 'country',
hover_name='country',
facet_col= 'region',
labels={'s':'Year of Schooling'},
title = "Overall Year of Schooling in Asia countries between 1990 and 2014")
px.histogram(df1[df1['region']=='Asia'],
x="s",
color="hi1990",
hover_name= 'country',
marginal='box',
animation_frame = 'year',
labels={'s':'Year of Schooling','hi1990':'developed country?'})
Year of Schooling and Human Capital in Asia
px.sunburst(df1[df1['region']=='Asia'],
color = "s",
values = "h",
path = ["region", "country"],
hover_name = "country",
labels={'s':'Year of Schooling'})
Human Capital and Labor Productivity in Asia
px.treemap(df1[df1['region']=='Asia'],
color = "h",
values = "lp",
path = ["region", "country"],
hover_name = "country",
labels={'h':'Human Capital'})
Year of Schooling - Human Capital - Labor Productivity
px.scatter(df1[df1['region']=='Asia'],
x="log_lp",
y="h",
size="s",
color="country",
hover_name="country",
animation_frame = 'year',
labels={'h':'Human Capital','log_lp':'Labor Productivity'},
log_x=True,
size_max=30)
Thailand
The Evolution of Education
px.line(df1.query("country=='Thailand'"), x="year", y="s",labels={'s':'Year of Schooling'},
title = "Year of Schooling in Thailand between 1990 and 2014")
The Evolution of Human Capital
px.line(df1.query("country=='Thailand'"), x="year", y="h",labels={'h':'Human Capital'},
title = "Human Capital in Thailand between 1990 and 2014")
The Relationship between Human Capital and GDP per Capita
px.scatter(df1.query("country=='Thailand'"),
x="GDPpc",
y="h",
labels={'h':'Human Capital','GDPpc':'GDP per Capita'},
animation_frame="year",
size="log_lp",
log_x=True, size_max=45,range_x=[1000,100000], range_y=[1,4],
title = "The Relationship between Human Capital and GDP per Capita in Thailand")
Compare the Evolution of Thailand with other countries
Education
px.line(
df1.query("country==['South Korea', 'Thailand','Nepal']"),
x="year",
y="s",
color="country",
labels={'s':'Year of Schooling'}
)
GDP per Capita
px.line(df1.query("country==['South Korea', 'Thailand','Nepal']"),
x="year",
y="GDPpc",
color="country",
labels={'GDPpc':'GDP per Capita'}
)
GDP per Capita and Human Capital
px.scatter(df1.query("country==['South Korea', 'Thailand','Nepal']"),
x="GDPpc",
y="h",
labels={'h':'Human Capital','GDPpc':'GDP per Capita'},
animation_frame="year",
color='country',
size="lp",
log_x=True, size_max=45,range_x=[1000,100000], range_y=[1,6],
title = "The Relationship between Human Capital and GDP per Capita")