In [1]:
import os
import wbdata
import pandas as pd
In [2]:
dir_df = os.path.join(os.path.abspath(''),'stg')
In [3]:
# List of datasource -> 16 Healt
# wbdata.get_source()
In [4]:
# Lista di indicatori -> SP.DYN.LE00.IN Life expectancy at birth, total (years)
# wbdata.get_indicator(source=16)
In [5]:
#wbdata.search_countries("ital")
In [6]:
# Interessato solo all'Italia -> Resitutisce un Dictionary
dc = wbdata.get_data("SP.DYN.LE00.IN", country='ITA')
In [7]:
# Trasformo in DataFrame
df = pd.DataFrame(dc)
In [8]:
df.drop(['decimal','indicator','country'], axis=1, inplace=True)
df.rename(columns={'value': 'Speranza di vita alla nascita'}, inplace=True)
In [9]:
df.head(2)
Out[9]:
In [10]:
df_filename = r'df_g3.pkl'
df_fullpath = os.path.join(dir_df, df_filename)
df.to_pickle(df_fullpath)