from IPython.display import YouTubeVideo
YouTubeVideo('jDlHNdIeEJk')
import numpy as np
import pandas as pd
#import geopandas as gpd
import matplotlib.pyplot as plt
import seaborn as sns
#import statsmodels.formula.api as smf
#import statsmodels.base.model as smclass
#import linearmodels as plm
# Set diplay options to two decimals
pd.set_option('display.float_format', '{:.2f}'.format)
# import data with multi-index
df1 = pd.read_stata('https://www.rug.nl/ggdc/docs/pwt91.dta')
df1 = df1.set_index(["country", "year"])
df1
## consumption per capita
df1["cPop"] = df1["rconna"]/df1["pop"]
## labor productivity (Output per worker)
df1["lp"] = df1["rgdpna"]/df1["emp"]
## labor force participation rate
df1["ePop"] = df1["emp"]/df1["pop"]
## non-savings rate
df1["ns"] = df1["cPop"]/(df1["lp"]*df1["ePop"])
# plot the evolution of consumption per capita of Japan
df_cPop_Japan = df1.loc["Japan","cPop"]
df_cPop_Japan.plot()
# plot the evolution of the non-savings share of Japan
df_ns_Japan = df1.loc["Japan","ns"]
df_ns_Japan.plot()
# plot the evolution of the labor force participation of Japan
df_ePop_Japan = df1.loc["Japan","ePop"]
df_ePop_Japan.plot()
# plot the evolution of the labor productivity of Japan
df_lp_Japan = df1.loc["Japan","lp"]
df_lp_Japan.plot()
# plot the evolution of consumption per capita of China
df_cPop_China = df1.loc["China","cPop"]
df_cPop_China.plot()
# plot the evolution of the non-savings share of China
df_ns_China = df1.loc["China","ns"]
df_ns_China.plot()
# plot the evolution of the labor force participation of China
df_ePop_China = df1.loc["China","ePop"]
df_ePop_China.plot()
# plot the evolution of the labor productivity of China
df_lp_China = df1.loc["China","lp"]
df_lp_China.plot()