import pandas as pd import wbdata as wb import pydygraphs over65ind = {"SP.POP.65UP.TO.ZS": "pctover65"} countries = ["IT", "NL", "ES"] df_all = wb.get_dataframe(over65ind, country = countries, data_date = (pd.datetime(1960, 1, 1), pd.datetime(2012, 1, 1))) df_all = df_all.reset_index() df_all.head() wide = pd.pivot_table(df_all, values = 'pctover65', index = 'date', columns = 'country').reset_index() wide['date'] = wide['date'].astype(float) wide.head() ## Dataframe example fig2 = pydygraphs.figure() xaxis = 'date' fig2.plotDataFrame(wide, xaxis) fig2.title("Percent of population over age 65") fig2.xlabel("Year") fig2.ylabel("Percent over 65") fig2.show()