Using Bokeh to Map Internet Usage and GDP over Time

This post by Ramiro Gomez is nice: it shows the number of internet users by country and gdp and allows to evolve this graph in time. Given that this animation looks a lot like this gapminder animation, I would like to try and replicate this plot using Bokeh. One of my incentives for doing so is also to add a slider instead of the implicit bottom-right interaction.

Getting the data and cleaning it

Ramiro Gomez has created a repository for the data he is using, but the data points themselves are not directly downloadable in text form. Therefore I decided to get it in raw form from the world bank website and export it as an Excel file. Let's load the data and look at it:

In [1]:
import numpy as np
In [2]:
import pandas as pd
In [3]:
df = pd.read_excel('files/InternetUsers_GDP.xlsx')

Let's have a quick look at head of the data:

In [4]:
df.head()
Out[4]:
Series Name Series Code Country Name Country Code 1991 [YR1991] 1992 [YR1992] 1993 [YR1993] 1994 [YR1994] 1995 [YR1995] 1996 [YR1996] ... 2006 [YR2006] 2007 [YR2007] 2008 [YR2008] 2009 [YR2009] 2010 [YR2010] 2011 [YR2011] 2012 [YR2012] 2013 [YR2013] 2014 [YR2014] 2015 [YR2015]
0 Internet users (per 100 people) IT.NET.USER.P2 Afghanistan AFG .. .. .. .. .. .. ... 2.10712 1.9 1.84 3.55 4 5 5.45455 5.9 6.39 ..
1 Internet users (per 100 people) IT.NET.USER.P2 Albania ALB .. .. .. .. 0.0111687 0.0321968 ... 9.60999 15.0361 23.86 41.2 45 49 54.656 57.2 60.1 ..
2 Internet users (per 100 people) IT.NET.USER.P2 Algeria DZA .. .. .. 0.000360674 0.00176895 0.00173853 ... 7.37598 9.45119 10.18 11.23 12.5 14 15.228 16.5 18.09 ..
3 Internet users (per 100 people) IT.NET.USER.P2 American Samoa ASM .. .. .. .. .. .. ... .. .. .. .. .. .. .. .. .. ..
4 Internet users (per 100 people) IT.NET.USER.P2 Andorra ADO .. .. .. .. .. 1.5266 ... 48.9368 70.87 70.04 78.53 81 81 86.4344 94 95.9 ..

5 rows × 29 columns

The columns feature the years, while the countries represented are in the rows.

In [5]:
df.columns
Out[5]:
Index(['Series Name', 'Series Code', 'Country Name', 'Country Code',
       '1991 [YR1991]', '1992 [YR1992]', '1993 [YR1993]', '1994 [YR1994]',
       '1995 [YR1995]', '1996 [YR1996]', '1997 [YR1997]', '1998 [YR1998]',
       '1999 [YR1999]', '2000 [YR2000]', '2001 [YR2001]', '2002 [YR2002]',
       '2003 [YR2003]', '2004 [YR2004]', '2005 [YR2005]', '2006 [YR2006]',
       '2007 [YR2007]', '2008 [YR2008]', '2009 [YR2009]', '2010 [YR2010]',
       '2011 [YR2011]', '2012 [YR2012]', '2013 [YR2013]', '2014 [YR2014]',
       '2015 [YR2015]'],
      dtype='object')

We're now going to build three dataframes with this data:

  • population
  • internet use
  • gdp

Let's build the dataframe for internet use.

In [6]:
df_internet = df[df['Series Name'] == 'Internet users (per 100 people)'][['Country Name', '1991 [YR1991]', '1992 [YR1992]', '1993 [YR1993]', '1994 [YR1994]',
       '1995 [YR1995]', '1996 [YR1996]', '1997 [YR1997]', '1998 [YR1998]',
       '1999 [YR1999]', '2000 [YR2000]', '2001 [YR2001]', '2002 [YR2002]',
       '2003 [YR2003]', '2004 [YR2004]', '2005 [YR2005]', '2006 [YR2006]',
       '2007 [YR2007]', '2008 [YR2008]', '2009 [YR2009]', '2010 [YR2010]',
       '2011 [YR2011]', '2012 [YR2012]', '2013 [YR2013]', '2014 [YR2014]',
       '2015 [YR2015]']]
In [7]:
df_internet.replace(to_replace='..', value=np.nan, inplace=True)
In [8]:
s = df_internet.pop('Country Name')
df_internet = df_internet.set_index(s)
df_internet
Out[8]:
1991 [YR1991] 1992 [YR1992] 1993 [YR1993] 1994 [YR1994] 1995 [YR1995] 1996 [YR1996] 1997 [YR1997] 1998 [YR1998] 1999 [YR1999] 2000 [YR2000] ... 2006 [YR2006] 2007 [YR2007] 2008 [YR2008] 2009 [YR2009] 2010 [YR2010] 2011 [YR2011] 2012 [YR2012] 2013 [YR2013] 2014 [YR2014] 2015 [YR2015]
Country Name
Afghanistan NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... 2.107124 1.900000 1.840000 3.550000 4.00 5.000000 5.454545 5.90000 6.39000 NaN
Albania NaN NaN NaN NaN 0.011169 0.032197 0.048594 0.065027 0.081437 0.114097 ... 9.609991 15.036115 23.860000 41.200000 45.00 49.000000 54.655959 57.20000 60.10000 NaN
Algeria NaN NaN NaN 0.000361 0.001769 0.001739 0.010268 0.020239 0.199524 0.491706 ... 7.375985 9.451191 10.180000 11.230000 12.50 14.000000 15.228027 16.50000 18.09000 NaN
American Samoa NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Andorra NaN NaN NaN NaN NaN 1.526601 3.050175 6.886209 7.635686 10.538836 ... 48.936847 70.870000 70.040000 78.530000 81.00 81.000000 86.434425 94.00000 95.90000 NaN
Angola NaN NaN NaN NaN NaN 0.000776 0.005674 0.018454 0.071964 0.105046 ... 1.907648 3.200000 4.600000 6.000000 10.00 14.776000 16.937210 19.10000 21.26000 NaN
Antigua and Barbuda NaN NaN NaN NaN 2.200769 2.858450 3.480537 4.071716 5.300681 6.482226 ... 30.000000 34.000000 38.000000 42.000000 47.00 52.000000 58.000000 63.40000 64.00000 NaN
Argentina NaN 0.002993 0.029527 0.043706 0.086277 0.141955 0.280340 0.830767 3.284482 7.038683 ... 20.927202 25.946633 28.112623 34.000000 45.00 51.000000 55.800000 59.90000 64.70000 NaN
Armenia NaN NaN NaN 0.009117 0.052743 0.094573 0.111651 0.128659 0.970738 1.300470 ... 5.631788 6.021253 6.210000 15.300000 25.00 32.000000 37.500000 41.90000 46.30000 NaN
Aruba NaN NaN NaN NaN NaN 2.768383 NaN NaN 4.506179 15.442823 ... 28.000000 30.900000 52.000000 58.000000 62.00 69.000000 74.000000 78.90000 83.78000 NaN
Australia 1.097204 1.768765 1.974611 2.232101 2.759655 3.275250 16.369358 30.813239 40.783784 46.756116 ... 66.000000 69.450000 71.670000 74.250000 76.00 79.487698 79.000000 83.00000 84.56000 NaN
Austria 0.259082 0.642818 0.765343 1.393423 1.890211 6.909162 9.533974 15.421219 23.044317 33.730133 ... 63.600000 69.370000 72.870000 73.450000 75.17 78.739993 80.029994 80.61880 81.00000 NaN
Azerbaijan NaN NaN NaN 0.001431 0.002056 0.006355 0.025188 0.037485 0.099229 0.147758 ... 11.992177 14.540000 17.080000 27.400000 46.00 50.000000 54.200000 58.70000 61.00000 NaN
Bahamas, The NaN NaN NaN NaN 0.960031 1.746951 1.362954 2.335591 3.764558 8.000000 ... 26.000000 27.000000 31.540000 33.880000 43.00 65.000000 71.748203 72.00000 76.92000 NaN
Bahrain NaN NaN NaN NaN 0.346206 0.843254 1.646299 3.218202 4.720358 6.153733 ... 28.243952 32.910000 51.950000 53.000000 55.00 76.999967 88.000000 90.00004 90.99998 NaN
Bangladesh NaN NaN NaN NaN NaN NaN 0.000751 0.003685 0.036170 0.071039 ... 1.000000 1.800000 2.500000 3.100000 3.70 4.500000 5.000000 6.63000 9.60000 NaN
Barbados NaN NaN NaN NaN 0.007752 0.389464 0.783429 1.970249 2.376247 3.973678 ... 55.300000 58.200000 61.400000 64.700000 65.10 67.000000 70.000000 73.00000 76.67000 NaN
Belarus NaN NaN NaN 0.000486 0.002921 0.029298 0.049021 0.073869 0.494881 1.860398 ... 16.200000 19.700000 23.000000 27.430000 31.80 39.648896 46.910000 54.17000 59.02000 NaN
Belgium 0.020073 0.100041 0.199446 0.695995 0.991663 2.968412 4.938081 7.886623 13.772214 29.431692 ... 59.720000 64.440000 66.000000 70.000000 75.00 81.609996 80.719991 82.17020 85.00000 NaN
Belize NaN NaN NaN NaN 0.045397 0.882807 1.288582 2.091516 4.076741 5.963835 ... 24.000000 24.600000 26.300000 27.200000 28.20 30.700000 31.000000 33.60000 38.70000 NaN
Benin NaN NaN NaN NaN NaN 0.001693 0.024649 0.047877 0.154907 0.225248 ... 1.537854 1.790000 1.850000 2.240000 3.13 4.148323 4.500000 4.90000 5.30000 NaN
Bermuda NaN NaN NaN NaN 6.838163 16.202466 24.189257 32.103759 39.947589 42.949860 ... 69.899655 74.350594 82.300000 83.250000 84.21 88.336000 91.299305 95.30000 96.80000 NaN
Bhutan NaN NaN NaN NaN NaN NaN NaN NaN 0.137572 0.400944 ... 4.518317 5.920000 6.550000 7.170000 13.60 21.000000 24.000000 29.90000 34.37000 NaN
Bolivia NaN NaN NaN NaN 0.066808 0.196081 0.447839 0.626484 0.981815 1.442764 ... 6.200671 10.499244 12.500000 16.800000 22.40 30.000000 35.340000 36.94000 39.02000 NaN
Bosnia and Herzegovina NaN NaN NaN NaN NaN 0.015126 0.059426 0.143671 0.194374 1.082961 ... 25.122386 27.920000 34.660000 37.740000 42.75 47.770000 52.780000 57.79000 60.80000 NaN
Botswana 0.000000 NaN NaN NaN 0.064521 0.157454 0.307747 0.602401 1.122391 2.902667 ... 4.289933 5.280000 6.250000 6.150000 6.00 8.000000 11.500000 15.00000 18.50000 NaN
Brazil 0.003288 0.012946 0.025498 0.037673 0.105138 0.450789 0.786079 1.477875 2.038732 2.870685 ... 28.178380 30.880000 33.830000 39.220000 40.65 45.690000 48.560000 51.04000 57.60000 NaN
Brunei Darussalam NaN NaN NaN NaN 1.017080 3.303350 4.831058 6.284743 7.671041 8.996285 ... 42.186349 44.680000 46.000000 49.000000 53.00 56.000000 60.273065 64.50000 68.77000 NaN
Bulgaria NaN NaN 0.002339 0.019527 0.119666 0.725251 1.219813 1.844965 2.908154 5.370923 ... 27.090000 33.640000 39.670000 45.000000 46.23 47.979993 51.899988 53.06150 55.49000 NaN
Burkina Faso NaN NaN NaN NaN NaN 0.000961 0.018686 0.045423 0.061780 0.077080 ... 0.632708 0.750000 0.920000 1.130000 2.40 3.000000 3.725035 9.10000 9.40000 NaN
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
Sweden 1.160519 1.497871 1.716364 3.412810 5.098024 9.043600 23.727948 33.467512 41.432783 45.687652 ... 87.760000 82.010000 90.000000 91.000000 90.00 92.769986 93.179988 94.78360 92.52000 NaN
Switzerland 1.179956 1.751713 2.167270 2.720004 3.552007 4.549657 15.100000 24.800000 34.000000 47.100000 ... 75.700000 77.200000 79.200000 81.300000 83.90 85.193028 85.200000 86.34000 87.00000 NaN
Syrian Arab Republic 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.032608 0.063687 0.124295 0.181699 ... 7.832552 11.500000 14.000000 17.300000 20.70 22.500000 24.300100 26.20000 28.09000 NaN
Tajikistan NaN NaN NaN NaN NaN NaN NaN NaN 0.032792 0.048600 ... 3.772406 7.197620 8.780000 10.070000 11.55 13.030000 14.510000 16.00000 17.49000 NaN
Tanzania NaN NaN NaN NaN NaN 0.001622 0.007900 0.009244 0.075131 0.117194 ... 1.300000 1.600000 1.900000 2.400000 2.90 3.200000 3.950000 4.40000 4.86000 NaN
Thailand 0.000052 0.000344 0.013581 0.038614 0.074825 0.115472 0.360522 1.091219 2.426242 3.689041 ... 17.160715 20.030000 18.200000 20.100000 22.40 23.669926 26.460000 28.94000 34.89000 NaN
Timor-Leste NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... 0.116628 0.140959 0.163877 0.185252 0.21 0.900000 0.914700 1.10000 1.14000 NaN
Togo 0.000000 0.000000 0.000000 0.000000 0.000000 0.010929 0.211139 0.305584 0.590363 0.800000 ... 2.000000 2.200000 2.400000 2.600000 3.00 3.500000 4.000000 4.50000 5.70000 NaN
Tonga NaN NaN NaN NaN 0.123231 0.163793 0.510866 0.765134 1.017967 2.434398 ... 5.853944 7.179865 8.110770 10.000000 16.00 25.000000 33.000000 35.00000 40.00000 NaN
Trinidad and Tobago NaN NaN NaN NaN 0.158150 0.393081 1.173175 2.724825 5.814251 7.721411 ... 30.003749 32.300000 34.800000 44.300000 48.50 55.200000 59.516200 63.80000 65.10000 NaN
Tunisia NaN NaN NaN 0.007380 0.011192 0.027615 0.043657 0.107941 1.602495 2.750740 ... 12.986409 17.100000 27.530000 34.070000 36.80 39.100000 41.441600 43.80000 46.16000 NaN
Turkey NaN NaN 0.008458 0.049869 0.081691 0.192725 0.473695 0.698805 2.292118 3.761685 ... 18.240000 28.630000 34.370000 36.400000 39.82 43.065710 45.130000 46.25000 51.04000 NaN
Turkmenistan NaN NaN NaN NaN NaN NaN NaN NaN 0.045021 0.133282 ... 1.319573 1.406361 1.750000 1.950000 3.00 5.000000 7.195800 9.60000 12.20000 NaN
Turks and Caicos Islands NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Tuvalu NaN NaN NaN NaN NaN NaN NaN NaN NaN 5.241640 ... NaN 10.000000 15.000000 20.000000 25.00 30.000000 35.000000 37.00000 NaN NaN
Uganda NaN NaN NaN NaN 0.002863 0.004626 0.010319 0.065289 0.105544 0.163714 ... 2.529363 3.671965 7.900000 9.780000 12.50 13.013543 14.689600 16.20000 17.71000 NaN
Ukraine NaN NaN 0.000777 0.013641 0.043084 0.098580 0.198822 0.301076 0.405385 0.716184 ... 4.506125 6.550000 11.000000 17.900000 23.30 28.708263 35.270000 41.00000 43.40000 NaN
United Arab Emirates NaN NaN NaN NaN 0.102939 0.375394 3.295593 6.908303 14.942699 23.625301 ... 52.000000 61.000000 63.000000 64.000000 68.00 78.000000 84.999992 88.00000 90.40000 NaN
United Kingdom 0.174231 0.260615 0.519762 1.036609 1.895168 4.123650 7.385399 13.669983 21.293638 26.821754 ... 68.820000 75.090000 78.390000 83.560000 85.00 85.379999 87.479998 89.84410 91.61000 NaN
United States 1.163194 1.724203 2.271673 4.862781 9.237088 16.419353 21.616401 30.093197 35.848724 43.079163 ... 68.931193 75.000000 74.000000 71.000000 71.69 69.729461 79.300000 84.20000 87.36000 NaN
Uruguay NaN NaN NaN 0.062474 0.310129 1.847472 3.363240 6.987069 9.972765 10.539058 ... 29.400000 34.000000 39.300000 41.800000 46.40 51.404661 54.453769 57.69000 61.46000 NaN
Uzbekistan NaN NaN NaN NaN 0.001527 0.004285 0.010537 0.020754 0.030688 0.484347 ... 6.388322 7.490605 9.080115 17.058216 20.00 30.200000 36.521300 38.20000 43.55000 NaN
Vanuatu NaN NaN NaN NaN NaN 0.056846 0.139506 0.274186 0.538300 2.108337 ... 5.850585 6.800000 7.269120 7.500000 8.00 9.200000 10.598000 11.30000 18.80000 NaN
Venezuela, RB NaN 0.012082 0.041587 0.055487 0.122215 0.248261 0.390959 1.383990 2.839826 3.359597 ... 15.224711 20.830000 25.880000 32.700000 37.37 40.220000 49.050083 54.90000 57.00000 NaN
Vietnam NaN NaN NaN NaN NaN 0.000135 0.003982 0.013079 0.128927 0.254248 ... 17.254562 20.755445 23.920000 26.550000 30.65 35.070000 39.490000 43.90000 48.31000 NaN
Virgin Islands (U.S.) NaN NaN NaN 0.940645 2.801958 4.647186 6.948369 9.245220 11.074606 13.815081 ... 27.332611 27.339336 27.361777 27.396510 31.22 35.600000 40.547900 45.30000 50.07000 NaN
West Bank and Gaza NaN NaN NaN NaN NaN NaN NaN NaN NaN 1.111306 ... 18.410000 21.176000 24.358000 32.230000 37.40 41.080000 43.400000 46.60000 53.67000 NaN
Yemen, Rep. NaN NaN NaN NaN NaN 0.000621 0.015025 0.023323 0.056629 0.082500 ... 1.247824 5.010000 6.890000 9.960000 12.35 14.905000 17.446500 20.00000 22.55000 NaN
Zambia NaN NaN NaN 0.006776 0.008784 0.009069 0.009330 0.030226 0.147053 0.191072 ... 4.159913 4.870000 5.550000 6.310000 10.00 11.500000 13.468200 15.40000 17.34000 NaN
Zimbabwe NaN NaN NaN 0.001739 0.007684 0.016790 0.033080 0.081648 0.161676 0.401434 ... 9.791842 10.850000 11.400000 11.360000 11.50 15.700000 17.090000 18.50000 19.89000 NaN

214 rows × 25 columns

Let's now build the dataframe for GDP.

In [9]:
df_gdp = df[df['Series Name'] == 'GDP per capita (constant 2005 US$)'][['Country Name', '1991 [YR1991]', '1992 [YR1992]', '1993 [YR1993]', '1994 [YR1994]',
       '1995 [YR1995]', '1996 [YR1996]', '1997 [YR1997]', '1998 [YR1998]',
       '1999 [YR1999]', '2000 [YR2000]', '2001 [YR2001]', '2002 [YR2002]',
       '2003 [YR2003]', '2004 [YR2004]', '2005 [YR2005]', '2006 [YR2006]',
       '2007 [YR2007]', '2008 [YR2008]', '2009 [YR2009]', '2010 [YR2010]',
       '2011 [YR2011]', '2012 [YR2012]', '2013 [YR2013]', '2014 [YR2014]',
       '2015 [YR2015]']]
In [10]:
df_gdp.replace(to_replace='..', value=np.nan, inplace=True)
In [11]:
s = df_gdp.pop('Country Name')
df_gdp = df_gdp.set_index(s)
df_gdp
Out[11]:
1991 [YR1991] 1992 [YR1992] 1993 [YR1993] 1994 [YR1994] 1995 [YR1995] 1996 [YR1996] 1997 [YR1997] 1998 [YR1998] 1999 [YR1999] 2000 [YR2000] ... 2006 [YR2006] 2007 [YR2007] 2008 [YR2008] 2009 [YR2009] 2010 [YR2010] 2011 [YR2011] 2012 [YR2012] 2013 [YR2013] 2014 [YR2014] 2015 [YR2015]
Country Name
Afghanistan NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... 263.012374 291.128823 294.238183 347.208097 366.324813 377.292766 418.426197 413.233959 408.898697 NaN
Albania 1211.431789 1131.047006 1247.214425 1359.050613 1549.345209 1700.873966 1536.967481 1743.097819 1931.344256 2085.582721 ... 2939.136002 3136.159294 3398.487894 3536.231650 3685.568522 3790.101771 3857.339741 3916.231237 3994.625479 NaN
Algeria 2484.153186 2470.566078 2366.015901 2297.100086 2339.655291 2393.552046 2381.351303 2465.744244 2509.110754 2530.011442 ... 3109.768204 3167.388563 3179.776708 3176.744294 3233.176770 3262.063307 3304.701427 3330.802120 3400.732802 NaN
American Samoa NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Andorra 29833.095771 28970.387067 27685.024766 27574.571029 27825.961843 28921.863630 31615.216190 32757.517100 33955.180327 33700.762129 ... 40745.465162 40054.227486 36296.274603 34968.485540 33512.015532 32713.610776 33357.462074 34835.709370 NaN NaN
Angola 1376.983953 1241.205271 904.267859 906.193896 970.202243 1048.154225 1100.061612 1142.965689 1146.517824 1145.236277 ... 1838.473307 2178.362871 2397.088332 2373.831980 2373.765225 2385.576823 2426.366161 2507.085626 2521.102581 NaN
Antigua and Barbuda 9793.500455 9717.444050 10014.827235 10379.394318 9684.082744 10057.745742 10258.959051 10426.206800 10593.961477 10897.778167 ... 13547.711833 14671.133807 14517.635341 12629.713786 11602.142227 11275.280156 11607.745344 11481.385188 11731.963766 NaN
Argentina 4395.007076 4852.381210 5070.344112 5296.817066 5081.892652 5298.425979 5661.959372 5813.822438 5554.697946 5449.989077 ... 6108.427140 6527.158500 6659.230509 6594.499948 7143.504413 7662.156733 7642.930027 7781.549510 7737.715767 NaN
Armenia 1021.638633 605.352200 565.159435 610.113998 665.722822 715.818418 748.023547 808.996242 840.862615 895.603701 ... 1847.746891 2111.675685 2267.312170 1952.342100 1997.052261 2087.751968 2230.288855 2297.661964 2364.748214 NaN
Aruba NaN NaN NaN 23086.937951 22319.245642 23233.536705 24129.274973 23896.337025 24490.145798 23902.920892 ... 23662.635648 22710.463505 21121.812032 19913.149353 NaN NaN NaN NaN NaN NaN
Australia 24614.158791 24415.552742 25148.739610 25890.429700 26572.343112 27260.709823 28020.496871 28958.651599 30062.382901 30856.309781 ... 34499.830818 35574.154559 36159.264736 36035.071734 36175.112507 36504.134724 37218.157018 37497.070617 37828.254822 NaN
Austria 29753.671014 30044.090309 29954.335609 30556.054694 31323.284536 32031.241655 32700.463889 33827.439708 34973.738872 36064.962053 ... 39328.396166 40620.780680 41120.378092 39454.685642 40099.966160 41192.520494 41367.558194 41220.410466 41077.363602 NaN
Azerbaijan 1631.653004 1243.909737 942.144708 746.384598 650.772968 652.609267 683.831939 745.109350 793.255211 874.096083 ... 2099.709751 2596.062924 2815.965380 3017.660145 3126.724040 3088.281619 3114.562464 3252.757665 3275.714287 NaN
Bahamas, The 21058.554119 19871.219956 19562.500337 19831.987589 20386.495944 20974.923944 21170.551223 21933.189330 23218.512733 23831.302453 ... 23526.365660 23416.345318 22456.959177 21143.684034 21109.069382 20897.843209 21035.565253 20736.547344 20663.546866 NaN
Bahrain 15798.809584 16433.540159 18100.346984 17612.588167 17831.369670 18047.993111 18046.662197 18292.410136 18398.765054 18619.953568 ... 18071.354373 17935.031185 17531.597008 16760.195798 16591.813141 16360.534145 16597.383021 17277.920973 17890.835517 NaN
Bangladesh 327.207090 337.313508 345.562852 351.351448 361.504445 369.861872 378.377701 389.779719 399.817789 412.853985 ... 511.436582 540.987738 567.100643 589.141271 614.948382 647.066657 681.043739 713.270110 747.759329 NaN
Barbados 11772.802277 11148.130053 11219.507472 11624.635479 11755.691319 11927.267839 12642.255917 13112.783976 13404.179013 13665.824725 ... 14956.258883 15144.828581 15133.175246 14446.750204 14426.381153 14482.138718 14433.178929 12190.361030 12177.847426 NaN
Belarus 2299.857520 2074.593950 1912.618796 1690.824025 1519.882612 1567.667961 1753.804707 1910.187165 1981.825560 2103.058614 ... 3460.131302 3774.997459 4174.018811 4191.605273 4524.158168 4783.533470 4870.982917 4922.237626 4998.280896 NaN
Belgium 28932.699189 29256.615719 28862.242666 29701.941951 30346.632913 30757.203641 31831.440660 32400.812392 33527.905920 34634.193454 ... 37650.114306 38496.017527 38557.265293 37246.684222 37745.501704 37913.777577 37674.442707 37599.735498 37857.250933 NaN
Belize 2798.339677 3083.609628 3222.528203 3162.594313 3101.695600 3047.186690 3042.252041 3037.090126 3183.023913 3477.471782 ... 4007.728314 3948.130108 3972.292734 3901.732567 3935.100940 3925.328666 3984.514038 3957.321729 NaN NaN
Benin 460.598800 456.966157 465.945049 458.570603 470.135823 475.325384 487.968963 492.946670 504.331856 512.955285 ... 535.491121 543.283975 553.622810 551.917063 550.321696 552.616536 566.764040 582.927778 598.215917 NaN
Bermuda 53266.533612 53621.743106 54939.640207 54887.064220 56893.056157 58000.734428 60299.723355 62192.909866 63937.870912 69275.611137 ... 79630.812781 81436.341171 82192.926739 77419.158960 76393.831384 74483.142741 70626.253793 68637.690460 NaN NaN
Bhutan 641.741890 679.648335 705.490060 751.230889 808.301689 847.489671 878.391875 908.387249 954.294640 991.878349 ... 1311.936942 1514.077991 1555.418256 1628.872373 1788.579659 1898.090896 1963.611689 1974.747150 2069.845018 NaN
Bolivia 852.859103 849.983495 868.954723 891.730062 915.208297 936.469178 963.706309 992.577726 977.755845 983.431018 ... 1077.972919 1108.296485 1157.024474 1176.395890 1205.250274 1247.485668 1291.490323 1357.626077 1408.983654 NaN
Bosnia and Herzegovina NaN NaN NaN 522.959243 650.133071 1250.600872 1694.594066 1960.743665 2144.153416 2257.019003 ... 3016.709565 3221.385875 3396.576676 3299.469480 3324.709050 3359.133918 3321.893979 3408.627194 3456.504537 NaN
Botswana 3906.783575 3909.646565 3878.587479 3918.031838 4094.637591 4237.809346 4483.334545 4428.880583 4771.007984 4786.794755 ... 5655.887713 6036.267050 6291.250020 5695.946670 6061.050614 6298.854345 6469.690058 6930.853415 7095.693443 NaN
Brazil 3975.217942 3893.959395 4012.779679 4162.270308 4279.493849 4305.805410 4383.006380 4330.906788 4285.876865 4406.709060 ... 4865.200004 5101.581866 5303.038987 5238.572148 5580.965745 5744.486657 5791.319182 5896.096631 5852.523704 NaN
Brunei Darussalam 26896.749222 27386.845823 26711.312621 26812.815961 27293.233945 27388.196652 26349.549948 25613.050257 25829.183838 26023.341436 ... 27028.608498 26614.299493 25664.422339 24801.619242 25043.648346 25504.375830 25360.922604 24554.091379 25490.292632 NaN
Bulgaria 2643.509635 2477.728173 2460.601782 2513.858028 2597.301749 2652.503113 2639.641902 2749.333160 2608.684331 2779.901536 ... 4051.917389 4420.028066 4707.313450 4500.287155 4559.695447 4679.982144 4730.336431 4807.585808 4915.847676 NaN
Burkina Faso 288.159628 281.155937 283.111804 279.117522 287.080706 310.008866 320.538257 334.451217 349.220295 345.623687 ... 419.561918 429.930880 447.336165 446.711966 469.994714 485.889020 502.153664 520.164056 525.701278 NaN
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
Sweden 31740.196398 31188.986228 30367.840873 31385.306119 32477.487472 32918.020603 33853.411476 35264.742991 36833.575595 38515.855079 ... 44852.252331 46036.792562 45425.086992 42704.593904 44877.910174 45727.026094 45260.041839 45453.651561 46061.430992 NaN
Switzerland 48928.572822 48370.922611 47872.015717 48094.947912 48004.363409 48080.100482 49073.378320 50368.598234 50952.754998 52666.605566 ... 56639.886780 58460.183891 59036.542530 57061.845589 58138.630013 58533.321188 58557.468938 58996.896141 NaN NaN
Syrian Arab Republic 1162.974502 1282.741850 1312.016374 1373.784638 1413.149641 1434.856690 1420.604561 1470.186747 1382.109115 1386.882421 ... 1617.983244 1648.810221 NaN NaN NaN NaN NaN NaN NaN NaN
Tajikistan 652.709584 454.559006 373.679383 289.660216 250.157565 205.612397 206.481764 214.693951 219.648558 234.340660 ... 356.023443 375.713309 396.729617 402.870090 419.620869 440.662538 463.139828 486.315605 507.389499 NaN
Tanzania 353.081117 343.448345 336.242943 330.841072 332.638737 338.330787 341.347478 345.366970 353.326405 361.656988 ... 456.725627 481.225975 493.237428 504.494920 520.691812 545.136758 556.056818 578.672725 600.664946 NaN
Thailand 1686.894502 1806.346459 1939.403328 2096.240244 2268.887709 2378.189994 2319.775076 2052.037856 2118.301376 2193.461497 ... 2800.675102 2934.009787 3002.388913 2928.254191 3150.157583 3142.646358 3333.608515 3415.365989 3425.699081 NaN
Timor-Leste NaN NaN NaN NaN NaN NaN NaN NaN 438.458521 511.490388 ... 464.777800 509.221020 571.689161 634.870973 682.596437 745.007105 783.463509 803.755799 834.592881 NaN
Togo 411.836173 385.765712 319.743589 358.917269 377.717519 400.925453 447.016066 425.558088 424.835420 410.519476 ... 383.950047 382.193636 380.208899 382.999571 387.640001 395.715284 407.965430 417.508485 429.778711 NaN
Tonga 1943.174719 1945.682620 2016.067935 2112.685456 2186.284222 2180.028120 2169.220148 2218.749919 2293.965901 2359.157959 ... 2521.509527 2390.657282 2433.964337 2446.450901 2535.344499 2575.510436 2580.278989 2502.405101 2545.234451 NaN
Trinidad and Tobago 6653.511614 6503.830199 6373.928157 6569.788724 6804.116862 7053.745331 7231.225385 7781.507366 8108.638814 8584.307314 ... 13949.991780 14544.927257 14968.490694 14243.403983 14203.519745 13905.912796 14046.074147 14200.314976 NaN NaN
Tunisia 2071.209982 2187.725121 2214.168690 2229.027711 2237.690165 2362.830789 2457.433168 2542.325222 2661.295579 2758.458891 ... 3366.566652 3542.199307 3672.703241 3764.869696 3847.585473 3782.588677 3920.815594 3979.426155 NaN NaN
Turkey 4964.937145 5130.705953 5435.968875 5101.131843 5417.108942 5725.961424 6063.714044 6107.528148 5811.913867 6112.953417 ... 7514.483507 7773.568769 7732.584883 7264.723152 7814.899476 8397.248392 8471.748352 8719.730263 8860.768115 NaN
Turkmenistan 2033.195161 1680.084848 1658.319719 1336.742661 1213.098551 1270.209388 1107.678001 1170.317080 1346.831339 1404.083552 ... 1872.954718 2055.839116 2329.525141 2441.216377 2632.427447 2981.136092 3269.666734 3557.001679 3873.768140 NaN
Turks and Caicos Islands NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Tuvalu 1835.690337 1877.143051 1944.693157 2135.338571 2019.903075 1891.902882 2073.544014 2385.731556 2338.402682 2304.642685 ... 2292.095972 2429.667970 2617.201598 2496.084645 2423.261486 2623.569044 2623.881334 2653.638130 NaN NaN
Uganda 203.525973 203.704571 213.691208 220.325701 238.230848 252.081995 257.141033 261.816302 274.431071 274.340830 ... 344.332237 360.963906 379.462920 393.617696 400.453446 424.949038 429.402939 429.227930 434.223099 NaN
Ukraine 2413.565227 2173.213267 1863.015630 1442.889816 1276.909572 1159.462439 1134.972663 1123.403778 1131.778443 1210.678891 ... 1975.514154 2144.339196 2205.569047 1887.505505 1974.610008 2084.770609 2094.108288 2098.882105 2081.044598 NaN
United Arab Emirates 46527.725984 45563.789512 43778.263932 44488.693086 45203.912352 45547.185676 46856.843155 44611.980071 43512.558957 45610.666361 ... 38363.007054 34059.706336 30613.283238 25976.648243 24423.523976 24428.130127 24948.699493 25992.176376 26792.504870 NaN
United Kingdom 28336.628971 28386.413331 29067.629253 30160.707655 30842.194049 31584.174362 32307.090163 33344.006956 34280.256729 35445.360061 ... 40848.277990 41567.277201 41104.473693 39036.231764 39471.731251 39808.693995 39793.393295 40199.316944 40967.698535 NaN
United States 32537.699274 33230.459156 33695.616711 34628.879700 35149.387482 36061.615329 37228.767279 38434.753167 39776.100559 40945.633967 ... 45052.921324 45420.187491 44861.390969 43235.558538 43961.168507 44324.944379 45008.614091 45660.733764 46405.259222 NaN
Uruguay 4070.778061 4361.895681 4444.982659 4733.712395 4631.620458 4854.994175 5232.968302 5434.352333 5301.297452 5180.320568 ... 5426.077865 5765.950272 6159.285387 6397.877786 6873.312262 7204.218838 7419.204610 7771.948054 8016.680636 NaN
Uzbekistan 532.939764 462.284708 441.504291 410.409699 399.433144 398.527562 411.421150 422.261022 435.696435 446.037963 ... 579.576154 625.665999 673.696613 716.080800 755.322265 796.350418 849.059692 902.773319 960.048048 NaN
Vanuatu 1848.478429 1841.872580 1802.611906 1913.247731 1886.345189 1890.202378 1946.788822 1995.522908 1966.078208 2040.738045 ... 1995.889863 2048.408726 2128.488900 2146.984363 2131.092886 2107.094816 2095.691890 2089.124126 NaN NaN
Venezuela, RB 5629.741565 5836.803961 5725.018664 5471.422571 5569.245133 5445.208077 5677.120652 5583.220237 5149.871490 5239.821714 ... 5873.313222 6283.685921 6510.387860 6204.395342 6019.880351 6179.257320 6433.632482 6429.204742 6088.075224 NaN
Vietnam 313.453423 334.546174 355.352565 380.318305 409.826497 440.991703 469.559115 489.061697 504.778570 531.858397 ... 740.055098 784.276205 819.916158 855.070048 900.493693 946.803418 986.013763 1028.628664 1077.909089 NaN
Virgin Islands (U.S.) NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
West Bank and Gaza NaN NaN NaN 879.607743 900.961888 924.121257 1095.845997 1345.218416 1546.899603 1358.873551 ... 1354.732178 1297.125425 1151.478443 1352.911484 1344.978811 1408.291834 1564.401466 1453.395379 1389.881437 NaN
Yemen, Rep. 664.401501 682.361349 673.895285 685.528801 694.354833 700.449157 713.870149 735.161508 741.998561 766.138663 ... 819.425322 823.090840 832.293179 842.861916 847.283175 700.354523 698.967525 709.469348 NaN NaN
Zambia 625.864451 599.570735 624.519311 556.466951 558.031705 577.212444 583.184788 565.264927 575.777102 582.624116 ... 726.114165 764.703143 800.527758 848.883534 908.747917 937.642189 970.765075 1004.714584 1032.802532 NaN
Zimbabwe 696.045420 618.541739 611.896826 655.576781 645.016709 700.186601 708.094156 718.580475 704.221091 675.798307 ... 423.219322 402.549347 326.568863 340.422901 372.287290 408.377273 441.916720 451.424191 455.102890 NaN

214 rows × 25 columns

Finally, let's build the dataframe for population:

In [12]:
df_pop = df[df['Series Name'] == 'Population, total'][['Country Name', '1991 [YR1991]', '1992 [YR1992]', '1993 [YR1993]', '1994 [YR1994]',
       '1995 [YR1995]', '1996 [YR1996]', '1997 [YR1997]', '1998 [YR1998]',
       '1999 [YR1999]', '2000 [YR2000]', '2001 [YR2001]', '2002 [YR2002]',
       '2003 [YR2003]', '2004 [YR2004]', '2005 [YR2005]', '2006 [YR2006]',
       '2007 [YR2007]', '2008 [YR2008]', '2009 [YR2009]', '2010 [YR2010]',
       '2011 [YR2011]', '2012 [YR2012]', '2013 [YR2013]', '2014 [YR2014]',
       '2015 [YR2015]']]
In [13]:
df_pop.replace(to_replace='..', value=np.nan, inplace=True)
In [14]:
s = df_pop.pop('Country Name')
df_pop = df_pop.set_index(s)
df_pop
Out[14]:
1991 [YR1991] 1992 [YR1992] 1993 [YR1993] 1994 [YR1994] 1995 [YR1995] 1996 [YR1996] 1997 [YR1997] 1998 [YR1998] 1999 [YR1999] 2000 [YR2000] ... 2006 [YR2006] 2007 [YR2007] 2008 [YR2008] 2009 [YR2009] 2010 [YR2010] 2011 [YR2011] 2012 [YR2012] 2013 [YR2013] 2014 [YR2014] 2015 [YR2015]
Country Name
Afghanistan 12789374.0 13745630.0 14824371.0 15869967.0 16772522.0 17481800.0 18034130.0 18511480 19038420 19701940 ... 25183615 25877544 26528741 27207291 27962207 28809167 29726803 30682500 31627506 NaN
Albania 3266790.0 3247039.0 3227287.0 3207536.0 3187784.0 3168033.0 3148281.0 3128530 3108778 3089027 ... 2992547 2970017 2947314 2927519 2913021 2904780 2900489 2897366 2894475 NaN
Algeria 26554277.0 27180921.0 27785977.0 28362015.0 28904300.0 29411839.0 29887717.0 30336880 30766551 31183658 ... 33749328 34261971 34811059 35401790 36036159 36717132 37439427 38186135 38934334 NaN
American Samoa 48379.0 49597.0 50725.0 51807.0 52874.0 53926.0 54942.0 55899 56768 57522 ... 58648 57904 57031 56226 55636 55316 55227 55302 55434 NaN
Andorra 56674.0 58904.0 61003.0 62707.0 63854.0 64291.0 64147.0 63888 64161 65399 ... 83373 84878 85616 85474 84419 82326 79316 75902 72786 NaN
Angola 11472173.0 11848971.0 12246786.0 12648483.0 13042666.0 13424813.0 13801868.0 14187710 14601983 15058638 ... 18541467 19183907 19842251 20520103 21219954 21942296 22685632 23448202 24227524 NaN
Antigua and Barbuda 62412.0 63434.0 64868.0 66550.0 68349.0 70245.0 72232.0 74206 76041 77648 ... 83467 84397 85350 86300 87233 88152 89069 89985 90900 NaN
Argentina 33193920.0 33655149.0 34110912.0 34558114.0 34994818.0 35419683.0 35833965.0 36241578 36648054 37057453 ... 39558750 39969903 40381860 40798641 41222875 41655616 42095224 42538304 42980026 NaN
Armenia 3511912.0 3449497.0 3369673.0 3289943.0 3223173.0 3173425.0 3137652.0 3112958 3093820 3076098 ... 3002161 2988117 2975029 2966108 2963496 2967984 2978339 2992192 3006154 NaN
Aruba 64623.0 68235.0 72498.0 76700.0 80326.0 83195.0 85447.0 87276 89004 90858 ... 100830 101218 101342 101416 101597 101936 102393 102921 103441 NaN
Australia 17284000.0 17495000.0 17667000.0 17855000.0 18072000.0 18311000.0 18517000.0 18711000 18926000 19153000 ... 20697900 20827600 21249200 21691700 22031750 22340024 22728254 23125868 23490736 NaN
Austria 7754891.0 7840709.0 7905633.0 7936118.0 7948278.0 7959017.0 7968041.0 7976789 7992324 8011566 ... 8268641 8295487 8321496 8343323 8363404 8391643 8429991 8479375 8534492 NaN
Azerbaijan 7271000.0 7382000.0 7495000.0 7597000.0 7685000.0 7763000.0 7838250.0 7913000 7982750 8048600 ... 8484550 8581300 8763400 8947243 9054332 9173082 9295784 9416801 9537823 NaN
Bahamas, The 261117.0 266133.0 271165.0 275903.0 280151.0 283792.0 286968.0 290054 293572 297891 ... 335801 342259 348587 354780 360830 366711 372388 377841 383054 NaN
Bahrain 509654.0 522748.0 535692.0 549151.0 563730.0 579855.0 597834.0 618054 640904 666855 ... 940808 1026568 1115777 1196774 1261319 1306014 1333577 1349427 1361930 NaN
Bangladesh 108509679.0 110987459.0 113442354.0 115913710.0 118427768.0 120987124.0 123574107.0 126169583 128746273 131280739 ... 144839238 146592687 148252473 149905836 151616777 153405612 155257387 157157394 159077513 NaN
Barbados 261281.0 262184.0 263091.0 264015.0 264962.0 265940.0 266944.0 267949 268920 269838 ... 275040 276154 277315 278466 279566 280602 281580 282503 283380 NaN
Belarus 10194000.0 10216000.0 10239000.0 10227000.0 10194000.0 10160000.0 10117000.0 10069000 10035000 10005000 ... 9604000 9560000 9528000 9507000 9490000 9473000 9464000 9466000 9470000 NaN
Belgium 10004486.0 10045158.0 10084475.0 10115603.0 10136811.0 10156637.0 10181245.0 10203008 10226419 10251250 ... 10547958 10625700 10709973 10796493 10920272 11047744 11128246 11182817 11225207 NaN
Belize 191127.0 194321.0 197615.0 201678.0 206962.0 213674.0 221608.0 230289 239024 247312 ... 290751 298403 306165 313925 321609 329193 336707 344193 351706 NaN
Benin 5182525.0 5378226.0 5582420.0 5786794.0 5985658.0 6176318.0 6361301.0 6546493 6740491 6949366 ... 8443717 8707637 8973525 9240982 9509798 9779391 10049792 10322232 10598482 NaN
Bermuda 59021.0 58595.0 58910.0 59320.0 59746.0 60129.0 60497.0 60943 61285 61833 ... 64523 64888 65273 65636 65124 64564 64798 65001 65181 NaN
Bhutan 534678.0 528085.0 518847.0 511382.0 508897.0 512377.0 520917.0 533506 548387 564187 ... 666920 681471 694990 707830 720246 732246 743711 754637 765008 NaN
Bolivia 6992521.0 7131699.0 7273824.0 7418864.0 7566716.0 7717445.0 7870860.0 8026257 8182710 8339512 ... 9283345 9441482 9599916 9758799 9918245 10078238 10238762 10399931 10561887 NaN
Bosnia and Herzegovina 4437898.0 4301169.0 4141167.0 3992256.0 3879278.0 3810649.0 3779354.0 3775898 3784389 3792878 ... 3838504 3840418 3839749 3837732 3835258 3832310 3828419 3823533 3817554 NaN
Botswana 1420098.0 1460453.0 1500356.0 1539135.0 1576291.0 1611827.0 1645846.0 1678111 1708368 1736579 ... 1895671 1930431 1967866 2007212 2047831 2089706 2132822 2176510 2219937 NaN
Brazil 152916852.0 155379009.0 157812220.0 160260508.0 162755054.0 165303155.0 167893835.0 170516482 173153066 175786441 ... 190698241 192784521 194769696 196701298 198614208 200517584 202401584 204259377 206077898 NaN
Brunei Darussalam 264365.0 271989.0 279717.0 287423.0 295010.0 302449.0 309746.0 316873 323812 330554 ... 368150 374459 380786 387080 393302 399443 405512 411499 417394 NaN
Bulgaria 8632367.0 8540164.0 8472313.0 8443591.0 8406067.0 8362826.0 8312068.0 8256786 8210624 8170172 ... 7699020 7545338 7492561 7444443 7395599 7348328 7305888 7265115 7226291 NaN
Burkina Faso 9050090.0 9297116.0 9552473.0 9816586.0 10089876.0 10372809.0 10665781.0 10969093 11283016 11607944 ... 13834195 14264002 14709011 15165856 15632066 16106851 16590813 17084554 17589198 NaN
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
Sweden 8617375.0 8668067.0 8718561.0 8780745.0 8826939.0 8840998.0 8846062.0 8850974 8857874 8872109 ... 9080505 9148092 9219637 9298515 9378126 9449213 9519374 9600379 9689555 NaN
Switzerland 6799978.0 6875364.0 6938265.0 6993795.0 7040687.0 7071850.0 7088906.0 7110001 7143991 7184250 ... 7483934 7551117 7647675 7743831 7824909 7912398 7996861 8089346 8190229 NaN
Syrian Arab Republic 12817578.0 13186187.0 13559642.0 13941025.0 14331962.0 14736209.0 15151962.0 15568797 15972430 16354050 ... 18728200 19425597 20097057 20566871 20720602 21070917 21427155 21789415 22157800 NaN
Tajikistan 5417554.0 5523207.0 5616797.0 5702611.0 5784330.0 5862224.0 5936780.0 6012308 6094126 6186152 ... 6949566 7099021 7254072 7414960 7581696 7753925 7930929 8111894 8295840 NaN
Tanzania 26307482.0 27203865.0 28122799.0 29030288.0 29903329.0 30733937.0 31533781.0 32323953 33135281 33991590 ... 40260847 41522004 42844744 44222113 45648525 47122998 48645709 50213457 51822621 NaN
Thailand 57225972.0 57761574.0 58237672.0 58722767.0 59266089.0 59878955.0 60544937.0 61250974 61973957 62693322 ... 66174486 66353572 66453255 66548197 66692024 66902958 67164130 67451422 67725979 NaN
Timor-Leste 764884.0 792846.0 820471.0 842752.0 856439.0 859496.0 853867.0 845106 841063 847185 ... 996052 1013194 1030630 1048367 1066409 1120392 1148958 1180069 1212107 NaN
Togo 3886858.0 3984356.0 4081398.0 4180689.0 4284286.0 4392941.0 4506465.0 4624826 4747665 4874735 ... 5732175 5890414 6052937 6219761 6390851 6566179 6745581 6928719 7115163 NaN
Tonga 95304.0 95421.0 95532.0 95678.0 95889.0 96174.0 96526.0 96937 97398 97898 ... 101507 102169 102816 103416 103947 104392 104769 105139 105586 NaN
Trinidad and Tobago 1229906.0 1237486.0 1244410.0 1250316.0 1255001.0 1258365.0 1260677.0 1262544 1264781 1267980 ... 1303141 1309260 1315372 1321624 1328095 1334790 1341579 1348240 1354483 NaN
Tunisia 8318200.0 8489900.0 8572200.0 8785700.0 8957500.0 9089300.0 9214900.0 9333300 9455900 9552500 ... 10127900 10225100 10328900 10439600 10547100 10673800 10777500 10886500 10996600 NaN
Turkey 54909508.0 55811134.0 56707454.0 57608769.0 58522320.0 59451488.0 60394104.0 61344874 62295617 63240157 ... 68704721 69515492 70344357 71261307 72310416 73199372 74099255 75010202 75932348 NaN
Turkmenistan 3772350.0 3881973.0 3991917.0 4095512.0 4188010.0 4267690.0 4335991.0 4395293 4449427 4501419 ... 4801594 4858235 4917541 4978960 5041995 5106672 5172941 5240088 5307188 NaN
Turks and Caicos Islands 12205.0 12970.0 13793.0 14597.0 15334.0 15967.0 16527.0 17114 17866 18876 ... 27642 28638 29481 30247 30993 31727 32430 33103 33740 NaN
Tuvalu 9056.0 9103.0 9148.0 9188.0 9227.0 9264.0 9298.0 9334 9374 9419 ... 9732 9764 9788 9808 9827 9844 9860 9876 9893 NaN
Uganda 17973428.0 18571527.0 19177660.0 19791266.0 20412967.0 21041468.0 21679497.0 22336812 23026357 23757636 ... 29000925 29991958 31014427 32067125 33149417 34260342 35400620 36573387 37782971 NaN
Ukraine 52000470.0 52150266.0 52179210.0 51921041.0 51512299.0 51057189.0 50594105.0 50143939 49673350 49175848 ... 46787750 46509350 46258200 46053300 45870700 45706100 45593300 45489600 45362900 NaN
United Arab Emirates 1913190.0 2019014.0 2127863.0 2238281.0 2350192.0 2467726.0 2595220.0 2733770 2884188 3050128 ... 5171255 6010100 6900142 7705423 8329453 8734722 8952542 9039978 9086139 NaN
United Kingdom 57424897.0 57580402.0 57718614.0 57865745.0 58019030.0 58166950.0 58316954.0 58487141 58682466 58892514 ... 60846820 61322463 61806995 62276270 62766365 63258918 63700300 64106779 64510376 NaN
United States 252981000.0 256514000.0 259919000.0 263126000.0 266278000.0 269394000.0 272657000.0 275854000 279040000 282162411 ... 298379912 301231207 304093966 306771529 309347057 311721632 314112078 316497531 318857056 NaN
Uruguay 3132048.0 3154853.0 3178156.0 3201604.0 3224807.0 3248039.0 3271014.0 3292134 3309318 3321242 ... 3331041 3339750 3350832 3362761 3374414 3385610 3396753 3407969 3419516 NaN
Uzbekistan 20952000.0 21449000.0 21942000.0 22377000.0 22785000.0 23225000.0 23667000.0 24051000 24311650 24650400 ... 26488250 26868000 27302800 27767400 28562400 29339400 29774500 30243200 30742500 NaN
Vanuatu 150779.0 155242.0 159814.0 164209.0 168236.0 171802.0 175004.0 178074 181346 185058 ... 214635 219956 225335 230782 236299 241876 247498 253165 258883 NaN
Venezuela, RB 20332247.0 20799471.0 21263994.0 21726808.0 22188671.0 22649212.0 23108003.0 23565734 24023355 24481477 ... 27221228 27670659 28116716 28558607 28995745 29427631 29854238 30276045 30693827 NaN
Vietnam 67242400.0 68450100.0 69644500.0 70824500.0 71995500.0 73156700.0 74306900.0 75456300 76596700 77630900 ... 83311200 84218500 85118700 86025000 86932500 87840000 88772900 89708900 90730000 NaN
Virgin Islands (U.S.) 104807.0 105711.0 106577.0 107317.0 107817.0 108093.0 108355.0 108535 108596 108639 ... 107700 107423 107091 106707 106267 105784 105275 104737 104170 NaN
West Bank and Gaza 2068845.0 2163591.0 2262676.0 2366298.0 2474666.0 2587997.0 2706518.0 2776568 2848431 2922153 ... 3406334 3494496 3596688 3702218 3811102 3927051 4046901 4169506 4294682 NaN
Yemen, Rep. 12571240.0 13245003.0 13948118.0 14633091.0 15266147.0 15834747.0 16349809.0 16829935 17304422 17795219 ... 21093973 21701105 22322699 22954226 23591972 24234940 24882792 25533217 26183676 NaN
Zambia 8361381.0 8576987.0 8794061.0 9018229.0 9253527.0 9502346.0 9763742.0 10034412 10309310 10585220 ... 12381509 12738676 13114579 13507849 13917439 14343526 14786581 15246086 15721343 NaN
Zimbabwe 10763036.0 11019717.0 11256512.0 11476807.0 11683136.0 11877664.0 12059858.0 12226742 12374019 12499981 ... 13127942 13297798 13495462 13720997 13973897 14255592 14565482 14898092 15245855 NaN

214 rows × 25 columns

As a final step, we only keep a selection of countries from all these dataframes:

In [15]:
df_pop
Out[15]:
1991 [YR1991] 1992 [YR1992] 1993 [YR1993] 1994 [YR1994] 1995 [YR1995] 1996 [YR1996] 1997 [YR1997] 1998 [YR1998] 1999 [YR1999] 2000 [YR2000] ... 2006 [YR2006] 2007 [YR2007] 2008 [YR2008] 2009 [YR2009] 2010 [YR2010] 2011 [YR2011] 2012 [YR2012] 2013 [YR2013] 2014 [YR2014] 2015 [YR2015]
Country Name
Afghanistan 12789374.0 13745630.0 14824371.0 15869967.0 16772522.0 17481800.0 18034130.0 18511480 19038420 19701940 ... 25183615 25877544 26528741 27207291 27962207 28809167 29726803 30682500 31627506 NaN
Albania 3266790.0 3247039.0 3227287.0 3207536.0 3187784.0 3168033.0 3148281.0 3128530 3108778 3089027 ... 2992547 2970017 2947314 2927519 2913021 2904780 2900489 2897366 2894475 NaN
Algeria 26554277.0 27180921.0 27785977.0 28362015.0 28904300.0 29411839.0 29887717.0 30336880 30766551 31183658 ... 33749328 34261971 34811059 35401790 36036159 36717132 37439427 38186135 38934334 NaN
American Samoa 48379.0 49597.0 50725.0 51807.0 52874.0 53926.0 54942.0 55899 56768 57522 ... 58648 57904 57031 56226 55636 55316 55227 55302 55434 NaN
Andorra 56674.0 58904.0 61003.0 62707.0 63854.0 64291.0 64147.0 63888 64161 65399 ... 83373 84878 85616 85474 84419 82326 79316 75902 72786 NaN
Angola 11472173.0 11848971.0 12246786.0 12648483.0 13042666.0 13424813.0 13801868.0 14187710 14601983 15058638 ... 18541467 19183907 19842251 20520103 21219954 21942296 22685632 23448202 24227524 NaN
Antigua and Barbuda 62412.0 63434.0 64868.0 66550.0 68349.0 70245.0 72232.0 74206 76041 77648 ... 83467 84397 85350 86300 87233 88152 89069 89985 90900 NaN
Argentina 33193920.0 33655149.0 34110912.0 34558114.0 34994818.0 35419683.0 35833965.0 36241578 36648054 37057453 ... 39558750 39969903 40381860 40798641 41222875 41655616 42095224 42538304 42980026 NaN
Armenia 3511912.0 3449497.0 3369673.0 3289943.0 3223173.0 3173425.0 3137652.0 3112958 3093820 3076098 ... 3002161 2988117 2975029 2966108 2963496 2967984 2978339 2992192 3006154 NaN
Aruba 64623.0 68235.0 72498.0 76700.0 80326.0 83195.0 85447.0 87276 89004 90858 ... 100830 101218 101342 101416 101597 101936 102393 102921 103441 NaN
Australia 17284000.0 17495000.0 17667000.0 17855000.0 18072000.0 18311000.0 18517000.0 18711000 18926000 19153000 ... 20697900 20827600 21249200 21691700 22031750 22340024 22728254 23125868 23490736 NaN
Austria 7754891.0 7840709.0 7905633.0 7936118.0 7948278.0 7959017.0 7968041.0 7976789 7992324 8011566 ... 8268641 8295487 8321496 8343323 8363404 8391643 8429991 8479375 8534492 NaN
Azerbaijan 7271000.0 7382000.0 7495000.0 7597000.0 7685000.0 7763000.0 7838250.0 7913000 7982750 8048600 ... 8484550 8581300 8763400 8947243 9054332 9173082 9295784 9416801 9537823 NaN
Bahamas, The 261117.0 266133.0 271165.0 275903.0 280151.0 283792.0 286968.0 290054 293572 297891 ... 335801 342259 348587 354780 360830 366711 372388 377841 383054 NaN
Bahrain 509654.0 522748.0 535692.0 549151.0 563730.0 579855.0 597834.0 618054 640904 666855 ... 940808 1026568 1115777 1196774 1261319 1306014 1333577 1349427 1361930 NaN
Bangladesh 108509679.0 110987459.0 113442354.0 115913710.0 118427768.0 120987124.0 123574107.0 126169583 128746273 131280739 ... 144839238 146592687 148252473 149905836 151616777 153405612 155257387 157157394 159077513 NaN
Barbados 261281.0 262184.0 263091.0 264015.0 264962.0 265940.0 266944.0 267949 268920 269838 ... 275040 276154 277315 278466 279566 280602 281580 282503 283380 NaN
Belarus 10194000.0 10216000.0 10239000.0 10227000.0 10194000.0 10160000.0 10117000.0 10069000 10035000 10005000 ... 9604000 9560000 9528000 9507000 9490000 9473000 9464000 9466000 9470000 NaN
Belgium 10004486.0 10045158.0 10084475.0 10115603.0 10136811.0 10156637.0 10181245.0 10203008 10226419 10251250 ... 10547958 10625700 10709973 10796493 10920272 11047744 11128246 11182817 11225207 NaN
Belize 191127.0 194321.0 197615.0 201678.0 206962.0 213674.0 221608.0 230289 239024 247312 ... 290751 298403 306165 313925 321609 329193 336707 344193 351706 NaN
Benin 5182525.0 5378226.0 5582420.0 5786794.0 5985658.0 6176318.0 6361301.0 6546493 6740491 6949366 ... 8443717 8707637 8973525 9240982 9509798 9779391 10049792 10322232 10598482 NaN
Bermuda 59021.0 58595.0 58910.0 59320.0 59746.0 60129.0 60497.0 60943 61285 61833 ... 64523 64888 65273 65636 65124 64564 64798 65001 65181 NaN
Bhutan 534678.0 528085.0 518847.0 511382.0 508897.0 512377.0 520917.0 533506 548387 564187 ... 666920 681471 694990 707830 720246 732246 743711 754637 765008 NaN
Bolivia 6992521.0 7131699.0 7273824.0 7418864.0 7566716.0 7717445.0 7870860.0 8026257 8182710 8339512 ... 9283345 9441482 9599916 9758799 9918245 10078238 10238762 10399931 10561887 NaN
Bosnia and Herzegovina 4437898.0 4301169.0 4141167.0 3992256.0 3879278.0 3810649.0 3779354.0 3775898 3784389 3792878 ... 3838504 3840418 3839749 3837732 3835258 3832310 3828419 3823533 3817554 NaN
Botswana 1420098.0 1460453.0 1500356.0 1539135.0 1576291.0 1611827.0 1645846.0 1678111 1708368 1736579 ... 1895671 1930431 1967866 2007212 2047831 2089706 2132822 2176510 2219937 NaN
Brazil 152916852.0 155379009.0 157812220.0 160260508.0 162755054.0 165303155.0 167893835.0 170516482 173153066 175786441 ... 190698241 192784521 194769696 196701298 198614208 200517584 202401584 204259377 206077898 NaN
Brunei Darussalam 264365.0 271989.0 279717.0 287423.0 295010.0 302449.0 309746.0 316873 323812 330554 ... 368150 374459 380786 387080 393302 399443 405512 411499 417394 NaN
Bulgaria 8632367.0 8540164.0 8472313.0 8443591.0 8406067.0 8362826.0 8312068.0 8256786 8210624 8170172 ... 7699020 7545338 7492561 7444443 7395599 7348328 7305888 7265115 7226291 NaN
Burkina Faso 9050090.0 9297116.0 9552473.0 9816586.0 10089876.0 10372809.0 10665781.0 10969093 11283016 11607944 ... 13834195 14264002 14709011 15165856 15632066 16106851 16590813 17084554 17589198 NaN
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
Sweden 8617375.0 8668067.0 8718561.0 8780745.0 8826939.0 8840998.0 8846062.0 8850974 8857874 8872109 ... 9080505 9148092 9219637 9298515 9378126 9449213 9519374 9600379 9689555 NaN
Switzerland 6799978.0 6875364.0 6938265.0 6993795.0 7040687.0 7071850.0 7088906.0 7110001 7143991 7184250 ... 7483934 7551117 7647675 7743831 7824909 7912398 7996861 8089346 8190229 NaN
Syrian Arab Republic 12817578.0 13186187.0 13559642.0 13941025.0 14331962.0 14736209.0 15151962.0 15568797 15972430 16354050 ... 18728200 19425597 20097057 20566871 20720602 21070917 21427155 21789415 22157800 NaN
Tajikistan 5417554.0 5523207.0 5616797.0 5702611.0 5784330.0 5862224.0 5936780.0 6012308 6094126 6186152 ... 6949566 7099021 7254072 7414960 7581696 7753925 7930929 8111894 8295840 NaN
Tanzania 26307482.0 27203865.0 28122799.0 29030288.0 29903329.0 30733937.0 31533781.0 32323953 33135281 33991590 ... 40260847 41522004 42844744 44222113 45648525 47122998 48645709 50213457 51822621 NaN
Thailand 57225972.0 57761574.0 58237672.0 58722767.0 59266089.0 59878955.0 60544937.0 61250974 61973957 62693322 ... 66174486 66353572 66453255 66548197 66692024 66902958 67164130 67451422 67725979 NaN
Timor-Leste 764884.0 792846.0 820471.0 842752.0 856439.0 859496.0 853867.0 845106 841063 847185 ... 996052 1013194 1030630 1048367 1066409 1120392 1148958 1180069 1212107 NaN
Togo 3886858.0 3984356.0 4081398.0 4180689.0 4284286.0 4392941.0 4506465.0 4624826 4747665 4874735 ... 5732175 5890414 6052937 6219761 6390851 6566179 6745581 6928719 7115163 NaN
Tonga 95304.0 95421.0 95532.0 95678.0 95889.0 96174.0 96526.0 96937 97398 97898 ... 101507 102169 102816 103416 103947 104392 104769 105139 105586 NaN
Trinidad and Tobago 1229906.0 1237486.0 1244410.0 1250316.0 1255001.0 1258365.0 1260677.0 1262544 1264781 1267980 ... 1303141 1309260 1315372 1321624 1328095 1334790 1341579 1348240 1354483 NaN
Tunisia 8318200.0 8489900.0 8572200.0 8785700.0 8957500.0 9089300.0 9214900.0 9333300 9455900 9552500 ... 10127900 10225100 10328900 10439600 10547100 10673800 10777500 10886500 10996600 NaN
Turkey 54909508.0 55811134.0 56707454.0 57608769.0 58522320.0 59451488.0 60394104.0 61344874 62295617 63240157 ... 68704721 69515492 70344357 71261307 72310416 73199372 74099255 75010202 75932348 NaN
Turkmenistan 3772350.0 3881973.0 3991917.0 4095512.0 4188010.0 4267690.0 4335991.0 4395293 4449427 4501419 ... 4801594 4858235 4917541 4978960 5041995 5106672 5172941 5240088 5307188 NaN
Turks and Caicos Islands 12205.0 12970.0 13793.0 14597.0 15334.0 15967.0 16527.0 17114 17866 18876 ... 27642 28638 29481 30247 30993 31727 32430 33103 33740 NaN
Tuvalu 9056.0 9103.0 9148.0 9188.0 9227.0 9264.0 9298.0 9334 9374 9419 ... 9732 9764 9788 9808 9827 9844 9860 9876 9893 NaN
Uganda 17973428.0 18571527.0 19177660.0 19791266.0 20412967.0 21041468.0 21679497.0 22336812 23026357 23757636 ... 29000925 29991958 31014427 32067125 33149417 34260342 35400620 36573387 37782971 NaN
Ukraine 52000470.0 52150266.0 52179210.0 51921041.0 51512299.0 51057189.0 50594105.0 50143939 49673350 49175848 ... 46787750 46509350 46258200 46053300 45870700 45706100 45593300 45489600 45362900 NaN
United Arab Emirates 1913190.0 2019014.0 2127863.0 2238281.0 2350192.0 2467726.0 2595220.0 2733770 2884188 3050128 ... 5171255 6010100 6900142 7705423 8329453 8734722 8952542 9039978 9086139 NaN
United Kingdom 57424897.0 57580402.0 57718614.0 57865745.0 58019030.0 58166950.0 58316954.0 58487141 58682466 58892514 ... 60846820 61322463 61806995 62276270 62766365 63258918 63700300 64106779 64510376 NaN
United States 252981000.0 256514000.0 259919000.0 263126000.0 266278000.0 269394000.0 272657000.0 275854000 279040000 282162411 ... 298379912 301231207 304093966 306771529 309347057 311721632 314112078 316497531 318857056 NaN
Uruguay 3132048.0 3154853.0 3178156.0 3201604.0 3224807.0 3248039.0 3271014.0 3292134 3309318 3321242 ... 3331041 3339750 3350832 3362761 3374414 3385610 3396753 3407969 3419516 NaN
Uzbekistan 20952000.0 21449000.0 21942000.0 22377000.0 22785000.0 23225000.0 23667000.0 24051000 24311650 24650400 ... 26488250 26868000 27302800 27767400 28562400 29339400 29774500 30243200 30742500 NaN
Vanuatu 150779.0 155242.0 159814.0 164209.0 168236.0 171802.0 175004.0 178074 181346 185058 ... 214635 219956 225335 230782 236299 241876 247498 253165 258883 NaN
Venezuela, RB 20332247.0 20799471.0 21263994.0 21726808.0 22188671.0 22649212.0 23108003.0 23565734 24023355 24481477 ... 27221228 27670659 28116716 28558607 28995745 29427631 29854238 30276045 30693827 NaN
Vietnam 67242400.0 68450100.0 69644500.0 70824500.0 71995500.0 73156700.0 74306900.0 75456300 76596700 77630900 ... 83311200 84218500 85118700 86025000 86932500 87840000 88772900 89708900 90730000 NaN
Virgin Islands (U.S.) 104807.0 105711.0 106577.0 107317.0 107817.0 108093.0 108355.0 108535 108596 108639 ... 107700 107423 107091 106707 106267 105784 105275 104737 104170 NaN
West Bank and Gaza 2068845.0 2163591.0 2262676.0 2366298.0 2474666.0 2587997.0 2706518.0 2776568 2848431 2922153 ... 3406334 3494496 3596688 3702218 3811102 3927051 4046901 4169506 4294682 NaN
Yemen, Rep. 12571240.0 13245003.0 13948118.0 14633091.0 15266147.0 15834747.0 16349809.0 16829935 17304422 17795219 ... 21093973 21701105 22322699 22954226 23591972 24234940 24882792 25533217 26183676 NaN
Zambia 8361381.0 8576987.0 8794061.0 9018229.0 9253527.0 9502346.0 9763742.0 10034412 10309310 10585220 ... 12381509 12738676 13114579 13507849 13917439 14343526 14786581 15246086 15721343 NaN
Zimbabwe 10763036.0 11019717.0 11256512.0 11476807.0 11683136.0 11877664.0 12059858.0 12226742 12374019 12499981 ... 13127942 13297798 13495462 13720997 13973897 14255592 14565482 14898092 15245855 NaN

214 rows × 25 columns

In [16]:
selection = df_pop.index

df_pop = df_pop.loc[selection]
df_gdp = df_gdp.loc[selection]
df_internet = df_internet.loc[selection]
In [17]:
df_pop
Out[17]:
1991 [YR1991] 1992 [YR1992] 1993 [YR1993] 1994 [YR1994] 1995 [YR1995] 1996 [YR1996] 1997 [YR1997] 1998 [YR1998] 1999 [YR1999] 2000 [YR2000] ... 2006 [YR2006] 2007 [YR2007] 2008 [YR2008] 2009 [YR2009] 2010 [YR2010] 2011 [YR2011] 2012 [YR2012] 2013 [YR2013] 2014 [YR2014] 2015 [YR2015]
Country Name
Afghanistan 12789374.0 13745630.0 14824371.0 15869967.0 16772522.0 17481800.0 18034130.0 18511480 19038420 19701940 ... 25183615 25877544 26528741 27207291 27962207 28809167 29726803 30682500 31627506 NaN
Albania 3266790.0 3247039.0 3227287.0 3207536.0 3187784.0 3168033.0 3148281.0 3128530 3108778 3089027 ... 2992547 2970017 2947314 2927519 2913021 2904780 2900489 2897366 2894475 NaN
Algeria 26554277.0 27180921.0 27785977.0 28362015.0 28904300.0 29411839.0 29887717.0 30336880 30766551 31183658 ... 33749328 34261971 34811059 35401790 36036159 36717132 37439427 38186135 38934334 NaN
American Samoa 48379.0 49597.0 50725.0 51807.0 52874.0 53926.0 54942.0 55899 56768 57522 ... 58648 57904 57031 56226 55636 55316 55227 55302 55434 NaN
Andorra 56674.0 58904.0 61003.0 62707.0 63854.0 64291.0 64147.0 63888 64161 65399 ... 83373 84878 85616 85474 84419 82326 79316 75902 72786 NaN
Angola 11472173.0 11848971.0 12246786.0 12648483.0 13042666.0 13424813.0 13801868.0 14187710 14601983 15058638 ... 18541467 19183907 19842251 20520103 21219954 21942296 22685632 23448202 24227524 NaN
Antigua and Barbuda 62412.0 63434.0 64868.0 66550.0 68349.0 70245.0 72232.0 74206 76041 77648 ... 83467 84397 85350 86300 87233 88152 89069 89985 90900 NaN
Argentina 33193920.0 33655149.0 34110912.0 34558114.0 34994818.0 35419683.0 35833965.0 36241578 36648054 37057453 ... 39558750 39969903 40381860 40798641 41222875 41655616 42095224 42538304 42980026 NaN
Armenia 3511912.0 3449497.0 3369673.0 3289943.0 3223173.0 3173425.0 3137652.0 3112958 3093820 3076098 ... 3002161 2988117 2975029 2966108 2963496 2967984 2978339 2992192 3006154 NaN
Aruba 64623.0 68235.0 72498.0 76700.0 80326.0 83195.0 85447.0 87276 89004 90858 ... 100830 101218 101342 101416 101597 101936 102393 102921 103441 NaN
Australia 17284000.0 17495000.0 17667000.0 17855000.0 18072000.0 18311000.0 18517000.0 18711000 18926000 19153000 ... 20697900 20827600 21249200 21691700 22031750 22340024 22728254 23125868 23490736 NaN
Austria 7754891.0 7840709.0 7905633.0 7936118.0 7948278.0 7959017.0 7968041.0 7976789 7992324 8011566 ... 8268641 8295487 8321496 8343323 8363404 8391643 8429991 8479375 8534492 NaN
Azerbaijan 7271000.0 7382000.0 7495000.0 7597000.0 7685000.0 7763000.0 7838250.0 7913000 7982750 8048600 ... 8484550 8581300 8763400 8947243 9054332 9173082 9295784 9416801 9537823 NaN
Bahamas, The 261117.0 266133.0 271165.0 275903.0 280151.0 283792.0 286968.0 290054 293572 297891 ... 335801 342259 348587 354780 360830 366711 372388 377841 383054 NaN
Bahrain 509654.0 522748.0 535692.0 549151.0 563730.0 579855.0 597834.0 618054 640904 666855 ... 940808 1026568 1115777 1196774 1261319 1306014 1333577 1349427 1361930 NaN
Bangladesh 108509679.0 110987459.0 113442354.0 115913710.0 118427768.0 120987124.0 123574107.0 126169583 128746273 131280739 ... 144839238 146592687 148252473 149905836 151616777 153405612 155257387 157157394 159077513 NaN
Barbados 261281.0 262184.0 263091.0 264015.0 264962.0 265940.0 266944.0 267949 268920 269838 ... 275040 276154 277315 278466 279566 280602 281580 282503 283380 NaN
Belarus 10194000.0 10216000.0 10239000.0 10227000.0 10194000.0 10160000.0 10117000.0 10069000 10035000 10005000 ... 9604000 9560000 9528000 9507000 9490000 9473000 9464000 9466000 9470000 NaN
Belgium 10004486.0 10045158.0 10084475.0 10115603.0 10136811.0 10156637.0 10181245.0 10203008 10226419 10251250 ... 10547958 10625700 10709973 10796493 10920272 11047744 11128246 11182817 11225207 NaN
Belize 191127.0 194321.0 197615.0 201678.0 206962.0 213674.0 221608.0 230289 239024 247312 ... 290751 298403 306165 313925 321609 329193 336707 344193 351706 NaN
Benin 5182525.0 5378226.0 5582420.0 5786794.0 5985658.0 6176318.0 6361301.0 6546493 6740491 6949366 ... 8443717 8707637 8973525 9240982 9509798 9779391 10049792 10322232 10598482 NaN
Bermuda 59021.0 58595.0 58910.0 59320.0 59746.0 60129.0 60497.0 60943 61285 61833 ... 64523 64888 65273 65636 65124 64564 64798 65001 65181 NaN
Bhutan 534678.0 528085.0 518847.0 511382.0 508897.0 512377.0 520917.0 533506 548387 564187 ... 666920 681471 694990 707830 720246 732246 743711 754637 765008 NaN
Bolivia 6992521.0 7131699.0 7273824.0 7418864.0 7566716.0 7717445.0 7870860.0 8026257 8182710 8339512 ... 9283345 9441482 9599916 9758799 9918245 10078238 10238762 10399931 10561887 NaN
Bosnia and Herzegovina 4437898.0 4301169.0 4141167.0 3992256.0 3879278.0 3810649.0 3779354.0 3775898 3784389 3792878 ... 3838504 3840418 3839749 3837732 3835258 3832310 3828419 3823533 3817554 NaN
Botswana 1420098.0 1460453.0 1500356.0 1539135.0 1576291.0 1611827.0 1645846.0 1678111 1708368 1736579 ... 1895671 1930431 1967866 2007212 2047831 2089706 2132822 2176510 2219937 NaN
Brazil 152916852.0 155379009.0 157812220.0 160260508.0 162755054.0 165303155.0 167893835.0 170516482 173153066 175786441 ... 190698241 192784521 194769696 196701298 198614208 200517584 202401584 204259377 206077898 NaN
Brunei Darussalam 264365.0 271989.0 279717.0 287423.0 295010.0 302449.0 309746.0 316873 323812 330554 ... 368150 374459 380786 387080 393302 399443 405512 411499 417394 NaN
Bulgaria 8632367.0 8540164.0 8472313.0 8443591.0 8406067.0 8362826.0 8312068.0 8256786 8210624 8170172 ... 7699020 7545338 7492561 7444443 7395599 7348328 7305888 7265115 7226291 NaN
Burkina Faso 9050090.0 9297116.0 9552473.0 9816586.0 10089876.0 10372809.0 10665781.0 10969093 11283016 11607944 ... 13834195 14264002 14709011 15165856 15632066 16106851 16590813 17084554 17589198 NaN
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
Sweden 8617375.0 8668067.0 8718561.0 8780745.0 8826939.0 8840998.0 8846062.0 8850974 8857874 8872109 ... 9080505 9148092 9219637 9298515 9378126 9449213 9519374 9600379 9689555 NaN
Switzerland 6799978.0 6875364.0 6938265.0 6993795.0 7040687.0 7071850.0 7088906.0 7110001 7143991 7184250 ... 7483934 7551117 7647675 7743831 7824909 7912398 7996861 8089346 8190229 NaN
Syrian Arab Republic 12817578.0 13186187.0 13559642.0 13941025.0 14331962.0 14736209.0 15151962.0 15568797 15972430 16354050 ... 18728200 19425597 20097057 20566871 20720602 21070917 21427155 21789415 22157800 NaN
Tajikistan 5417554.0 5523207.0 5616797.0 5702611.0 5784330.0 5862224.0 5936780.0 6012308 6094126 6186152 ... 6949566 7099021 7254072 7414960 7581696 7753925 7930929 8111894 8295840 NaN
Tanzania 26307482.0 27203865.0 28122799.0 29030288.0 29903329.0 30733937.0 31533781.0 32323953 33135281 33991590 ... 40260847 41522004 42844744 44222113 45648525 47122998 48645709 50213457 51822621 NaN
Thailand 57225972.0 57761574.0 58237672.0 58722767.0 59266089.0 59878955.0 60544937.0 61250974 61973957 62693322 ... 66174486 66353572 66453255 66548197 66692024 66902958 67164130 67451422 67725979 NaN
Timor-Leste 764884.0 792846.0 820471.0 842752.0 856439.0 859496.0 853867.0 845106 841063 847185 ... 996052 1013194 1030630 1048367 1066409 1120392 1148958 1180069 1212107 NaN
Togo 3886858.0 3984356.0 4081398.0 4180689.0 4284286.0 4392941.0 4506465.0 4624826 4747665 4874735 ... 5732175 5890414 6052937 6219761 6390851 6566179 6745581 6928719 7115163 NaN
Tonga 95304.0 95421.0 95532.0 95678.0 95889.0 96174.0 96526.0 96937 97398 97898 ... 101507 102169 102816 103416 103947 104392 104769 105139 105586 NaN
Trinidad and Tobago 1229906.0 1237486.0 1244410.0 1250316.0 1255001.0 1258365.0 1260677.0 1262544 1264781 1267980 ... 1303141 1309260 1315372 1321624 1328095 1334790 1341579 1348240 1354483 NaN
Tunisia 8318200.0 8489900.0 8572200.0 8785700.0 8957500.0 9089300.0 9214900.0 9333300 9455900 9552500 ... 10127900 10225100 10328900 10439600 10547100 10673800 10777500 10886500 10996600 NaN
Turkey 54909508.0 55811134.0 56707454.0 57608769.0 58522320.0 59451488.0 60394104.0 61344874 62295617 63240157 ... 68704721 69515492 70344357 71261307 72310416 73199372 74099255 75010202 75932348 NaN
Turkmenistan 3772350.0 3881973.0 3991917.0 4095512.0 4188010.0 4267690.0 4335991.0 4395293 4449427 4501419 ... 4801594 4858235 4917541 4978960 5041995 5106672 5172941 5240088 5307188 NaN
Turks and Caicos Islands 12205.0 12970.0 13793.0 14597.0 15334.0 15967.0 16527.0 17114 17866 18876 ... 27642 28638 29481 30247 30993 31727 32430 33103 33740 NaN
Tuvalu 9056.0 9103.0 9148.0 9188.0 9227.0 9264.0 9298.0 9334 9374 9419 ... 9732 9764 9788 9808 9827 9844 9860 9876 9893 NaN
Uganda 17973428.0 18571527.0 19177660.0 19791266.0 20412967.0 21041468.0 21679497.0 22336812 23026357 23757636 ... 29000925 29991958 31014427 32067125 33149417 34260342 35400620 36573387 37782971 NaN
Ukraine 52000470.0 52150266.0 52179210.0 51921041.0 51512299.0 51057189.0 50594105.0 50143939 49673350 49175848 ... 46787750 46509350 46258200 46053300 45870700 45706100 45593300 45489600 45362900 NaN
United Arab Emirates 1913190.0 2019014.0 2127863.0 2238281.0 2350192.0 2467726.0 2595220.0 2733770 2884188 3050128 ... 5171255 6010100 6900142 7705423 8329453 8734722 8952542 9039978 9086139 NaN
United Kingdom 57424897.0 57580402.0 57718614.0 57865745.0 58019030.0 58166950.0 58316954.0 58487141 58682466 58892514 ... 60846820 61322463 61806995 62276270 62766365 63258918 63700300 64106779 64510376 NaN
United States 252981000.0 256514000.0 259919000.0 263126000.0 266278000.0 269394000.0 272657000.0 275854000 279040000 282162411 ... 298379912 301231207 304093966 306771529 309347057 311721632 314112078 316497531 318857056 NaN
Uruguay 3132048.0 3154853.0 3178156.0 3201604.0 3224807.0 3248039.0 3271014.0 3292134 3309318 3321242 ... 3331041 3339750 3350832 3362761 3374414 3385610 3396753 3407969 3419516 NaN
Uzbekistan 20952000.0 21449000.0 21942000.0 22377000.0 22785000.0 23225000.0 23667000.0 24051000 24311650 24650400 ... 26488250 26868000 27302800 27767400 28562400 29339400 29774500 30243200 30742500 NaN
Vanuatu 150779.0 155242.0 159814.0 164209.0 168236.0 171802.0 175004.0 178074 181346 185058 ... 214635 219956 225335 230782 236299 241876 247498 253165 258883 NaN
Venezuela, RB 20332247.0 20799471.0 21263994.0 21726808.0 22188671.0 22649212.0 23108003.0 23565734 24023355 24481477 ... 27221228 27670659 28116716 28558607 28995745 29427631 29854238 30276045 30693827 NaN
Vietnam 67242400.0 68450100.0 69644500.0 70824500.0 71995500.0 73156700.0 74306900.0 75456300 76596700 77630900 ... 83311200 84218500 85118700 86025000 86932500 87840000 88772900 89708900 90730000 NaN
Virgin Islands (U.S.) 104807.0 105711.0 106577.0 107317.0 107817.0 108093.0 108355.0 108535 108596 108639 ... 107700 107423 107091 106707 106267 105784 105275 104737 104170 NaN
West Bank and Gaza 2068845.0 2163591.0 2262676.0 2366298.0 2474666.0 2587997.0 2706518.0 2776568 2848431 2922153 ... 3406334 3494496 3596688 3702218 3811102 3927051 4046901 4169506 4294682 NaN
Yemen, Rep. 12571240.0 13245003.0 13948118.0 14633091.0 15266147.0 15834747.0 16349809.0 16829935 17304422 17795219 ... 21093973 21701105 22322699 22954226 23591972 24234940 24882792 25533217 26183676 NaN
Zambia 8361381.0 8576987.0 8794061.0 9018229.0 9253527.0 9502346.0 9763742.0 10034412 10309310 10585220 ... 12381509 12738676 13114579 13507849 13917439 14343526 14786581 15246086 15721343 NaN
Zimbabwe 10763036.0 11019717.0 11256512.0 11476807.0 11683136.0 11877664.0 12059858.0 12226742 12374019 12499981 ... 13127942 13297798 13495462 13720997 13973897 14255592 14565482 14898092 15245855 NaN

214 rows × 25 columns

In [18]:
df_gdp
Out[18]:
1991 [YR1991] 1992 [YR1992] 1993 [YR1993] 1994 [YR1994] 1995 [YR1995] 1996 [YR1996] 1997 [YR1997] 1998 [YR1998] 1999 [YR1999] 2000 [YR2000] ... 2006 [YR2006] 2007 [YR2007] 2008 [YR2008] 2009 [YR2009] 2010 [YR2010] 2011 [YR2011] 2012 [YR2012] 2013 [YR2013] 2014 [YR2014] 2015 [YR2015]
Country Name
Afghanistan NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... 263.012374 291.128823 294.238183 347.208097 366.324813 377.292766 418.426197 413.233959 408.898697 NaN
Albania 1211.431789 1131.047006 1247.214425 1359.050613 1549.345209 1700.873966 1536.967481 1743.097819 1931.344256 2085.582721 ... 2939.136002 3136.159294 3398.487894 3536.231650 3685.568522 3790.101771 3857.339741 3916.231237 3994.625479 NaN
Algeria 2484.153186 2470.566078 2366.015901 2297.100086 2339.655291 2393.552046 2381.351303 2465.744244 2509.110754 2530.011442 ... 3109.768204 3167.388563 3179.776708 3176.744294 3233.176770 3262.063307 3304.701427 3330.802120 3400.732802 NaN
American Samoa NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Andorra 29833.095771 28970.387067 27685.024766 27574.571029 27825.961843 28921.863630 31615.216190 32757.517100 33955.180327 33700.762129 ... 40745.465162 40054.227486 36296.274603 34968.485540 33512.015532 32713.610776 33357.462074 34835.709370 NaN NaN
Angola 1376.983953 1241.205271 904.267859 906.193896 970.202243 1048.154225 1100.061612 1142.965689 1146.517824 1145.236277 ... 1838.473307 2178.362871 2397.088332 2373.831980 2373.765225 2385.576823 2426.366161 2507.085626 2521.102581 NaN
Antigua and Barbuda 9793.500455 9717.444050 10014.827235 10379.394318 9684.082744 10057.745742 10258.959051 10426.206800 10593.961477 10897.778167 ... 13547.711833 14671.133807 14517.635341 12629.713786 11602.142227 11275.280156 11607.745344 11481.385188 11731.963766 NaN
Argentina 4395.007076 4852.381210 5070.344112 5296.817066 5081.892652 5298.425979 5661.959372 5813.822438 5554.697946 5449.989077 ... 6108.427140 6527.158500 6659.230509 6594.499948 7143.504413 7662.156733 7642.930027 7781.549510 7737.715767 NaN
Armenia 1021.638633 605.352200 565.159435 610.113998 665.722822 715.818418 748.023547 808.996242 840.862615 895.603701 ... 1847.746891 2111.675685 2267.312170 1952.342100 1997.052261 2087.751968 2230.288855 2297.661964 2364.748214 NaN
Aruba NaN NaN NaN 23086.937951 22319.245642 23233.536705 24129.274973 23896.337025 24490.145798 23902.920892 ... 23662.635648 22710.463505 21121.812032 19913.149353 NaN NaN NaN NaN NaN NaN
Australia 24614.158791 24415.552742 25148.739610 25890.429700 26572.343112 27260.709823 28020.496871 28958.651599 30062.382901 30856.309781 ... 34499.830818 35574.154559 36159.264736 36035.071734 36175.112507 36504.134724 37218.157018 37497.070617 37828.254822 NaN
Austria 29753.671014 30044.090309 29954.335609 30556.054694 31323.284536 32031.241655 32700.463889 33827.439708 34973.738872 36064.962053 ... 39328.396166 40620.780680 41120.378092 39454.685642 40099.966160 41192.520494 41367.558194 41220.410466 41077.363602 NaN
Azerbaijan 1631.653004 1243.909737 942.144708 746.384598 650.772968 652.609267 683.831939 745.109350 793.255211 874.096083 ... 2099.709751 2596.062924 2815.965380 3017.660145 3126.724040 3088.281619 3114.562464 3252.757665 3275.714287 NaN
Bahamas, The 21058.554119 19871.219956 19562.500337 19831.987589 20386.495944 20974.923944 21170.551223 21933.189330 23218.512733 23831.302453 ... 23526.365660 23416.345318 22456.959177 21143.684034 21109.069382 20897.843209 21035.565253 20736.547344 20663.546866 NaN
Bahrain 15798.809584 16433.540159 18100.346984 17612.588167 17831.369670 18047.993111 18046.662197 18292.410136 18398.765054 18619.953568 ... 18071.354373 17935.031185 17531.597008 16760.195798 16591.813141 16360.534145 16597.383021 17277.920973 17890.835517 NaN
Bangladesh 327.207090 337.313508 345.562852 351.351448 361.504445 369.861872 378.377701 389.779719 399.817789 412.853985 ... 511.436582 540.987738 567.100643 589.141271 614.948382 647.066657 681.043739 713.270110 747.759329 NaN
Barbados 11772.802277 11148.130053 11219.507472 11624.635479 11755.691319 11927.267839 12642.255917 13112.783976 13404.179013 13665.824725 ... 14956.258883 15144.828581 15133.175246 14446.750204 14426.381153 14482.138718 14433.178929 12190.361030 12177.847426 NaN
Belarus 2299.857520 2074.593950 1912.618796 1690.824025 1519.882612 1567.667961 1753.804707 1910.187165 1981.825560 2103.058614 ... 3460.131302 3774.997459 4174.018811 4191.605273 4524.158168 4783.533470 4870.982917 4922.237626 4998.280896 NaN
Belgium 28932.699189 29256.615719 28862.242666 29701.941951 30346.632913 30757.203641 31831.440660 32400.812392 33527.905920 34634.193454 ... 37650.114306 38496.017527 38557.265293 37246.684222 37745.501704 37913.777577 37674.442707 37599.735498 37857.250933 NaN
Belize 2798.339677 3083.609628 3222.528203 3162.594313 3101.695600 3047.186690 3042.252041 3037.090126 3183.023913 3477.471782 ... 4007.728314 3948.130108 3972.292734 3901.732567 3935.100940 3925.328666 3984.514038 3957.321729 NaN NaN
Benin 460.598800 456.966157 465.945049 458.570603 470.135823 475.325384 487.968963 492.946670 504.331856 512.955285 ... 535.491121 543.283975 553.622810 551.917063 550.321696 552.616536 566.764040 582.927778 598.215917 NaN
Bermuda 53266.533612 53621.743106 54939.640207 54887.064220 56893.056157 58000.734428 60299.723355 62192.909866 63937.870912 69275.611137 ... 79630.812781 81436.341171 82192.926739 77419.158960 76393.831384 74483.142741 70626.253793 68637.690460 NaN NaN
Bhutan 641.741890 679.648335 705.490060 751.230889 808.301689 847.489671 878.391875 908.387249 954.294640 991.878349 ... 1311.936942 1514.077991 1555.418256 1628.872373 1788.579659 1898.090896 1963.611689 1974.747150 2069.845018 NaN
Bolivia 852.859103 849.983495 868.954723 891.730062 915.208297 936.469178 963.706309 992.577726 977.755845 983.431018 ... 1077.972919 1108.296485 1157.024474 1176.395890 1205.250274 1247.485668 1291.490323 1357.626077 1408.983654 NaN
Bosnia and Herzegovina NaN NaN NaN 522.959243 650.133071 1250.600872 1694.594066 1960.743665 2144.153416 2257.019003 ... 3016.709565 3221.385875 3396.576676 3299.469480 3324.709050 3359.133918 3321.893979 3408.627194 3456.504537 NaN
Botswana 3906.783575 3909.646565 3878.587479 3918.031838 4094.637591 4237.809346 4483.334545 4428.880583 4771.007984 4786.794755 ... 5655.887713 6036.267050 6291.250020 5695.946670 6061.050614 6298.854345 6469.690058 6930.853415 7095.693443 NaN
Brazil 3975.217942 3893.959395 4012.779679 4162.270308 4279.493849 4305.805410 4383.006380 4330.906788 4285.876865 4406.709060 ... 4865.200004 5101.581866 5303.038987 5238.572148 5580.965745 5744.486657 5791.319182 5896.096631 5852.523704 NaN
Brunei Darussalam 26896.749222 27386.845823 26711.312621 26812.815961 27293.233945 27388.196652 26349.549948 25613.050257 25829.183838 26023.341436 ... 27028.608498 26614.299493 25664.422339 24801.619242 25043.648346 25504.375830 25360.922604 24554.091379 25490.292632 NaN
Bulgaria 2643.509635 2477.728173 2460.601782 2513.858028 2597.301749 2652.503113 2639.641902 2749.333160 2608.684331 2779.901536 ... 4051.917389 4420.028066 4707.313450 4500.287155 4559.695447 4679.982144 4730.336431 4807.585808 4915.847676 NaN
Burkina Faso 288.159628 281.155937 283.111804 279.117522 287.080706 310.008866 320.538257 334.451217 349.220295 345.623687 ... 419.561918 429.930880 447.336165 446.711966 469.994714 485.889020 502.153664 520.164056 525.701278 NaN
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
Sweden 31740.196398 31188.986228 30367.840873 31385.306119 32477.487472 32918.020603 33853.411476 35264.742991 36833.575595 38515.855079 ... 44852.252331 46036.792562 45425.086992 42704.593904 44877.910174 45727.026094 45260.041839 45453.651561 46061.430992 NaN
Switzerland 48928.572822 48370.922611 47872.015717 48094.947912 48004.363409 48080.100482 49073.378320 50368.598234 50952.754998 52666.605566 ... 56639.886780 58460.183891 59036.542530 57061.845589 58138.630013 58533.321188 58557.468938 58996.896141 NaN NaN
Syrian Arab Republic 1162.974502 1282.741850 1312.016374 1373.784638 1413.149641 1434.856690 1420.604561 1470.186747 1382.109115 1386.882421 ... 1617.983244 1648.810221 NaN NaN NaN NaN NaN NaN NaN NaN
Tajikistan 652.709584 454.559006 373.679383 289.660216 250.157565 205.612397 206.481764 214.693951 219.648558 234.340660 ... 356.023443 375.713309 396.729617 402.870090 419.620869 440.662538 463.139828 486.315605 507.389499 NaN
Tanzania 353.081117 343.448345 336.242943 330.841072 332.638737 338.330787 341.347478 345.366970 353.326405 361.656988 ... 456.725627 481.225975 493.237428 504.494920 520.691812 545.136758 556.056818 578.672725 600.664946 NaN
Thailand 1686.894502 1806.346459 1939.403328 2096.240244 2268.887709 2378.189994 2319.775076 2052.037856 2118.301376 2193.461497 ... 2800.675102 2934.009787 3002.388913 2928.254191 3150.157583 3142.646358 3333.608515 3415.365989 3425.699081 NaN
Timor-Leste NaN NaN NaN NaN NaN NaN NaN NaN 438.458521 511.490388 ... 464.777800 509.221020 571.689161 634.870973 682.596437 745.007105 783.463509 803.755799 834.592881 NaN
Togo 411.836173 385.765712 319.743589 358.917269 377.717519 400.925453 447.016066 425.558088 424.835420 410.519476 ... 383.950047 382.193636 380.208899 382.999571 387.640001 395.715284 407.965430 417.508485 429.778711 NaN
Tonga 1943.174719 1945.682620 2016.067935 2112.685456 2186.284222 2180.028120 2169.220148 2218.749919 2293.965901 2359.157959 ... 2521.509527 2390.657282 2433.964337 2446.450901 2535.344499 2575.510436 2580.278989 2502.405101 2545.234451 NaN
Trinidad and Tobago 6653.511614 6503.830199 6373.928157 6569.788724 6804.116862 7053.745331 7231.225385 7781.507366 8108.638814 8584.307314 ... 13949.991780 14544.927257 14968.490694 14243.403983 14203.519745 13905.912796 14046.074147 14200.314976 NaN NaN
Tunisia 2071.209982 2187.725121 2214.168690 2229.027711 2237.690165 2362.830789 2457.433168 2542.325222 2661.295579 2758.458891 ... 3366.566652 3542.199307 3672.703241 3764.869696 3847.585473 3782.588677 3920.815594 3979.426155 NaN NaN
Turkey 4964.937145 5130.705953 5435.968875 5101.131843 5417.108942 5725.961424 6063.714044 6107.528148 5811.913867 6112.953417 ... 7514.483507 7773.568769 7732.584883 7264.723152 7814.899476 8397.248392 8471.748352 8719.730263 8860.768115 NaN
Turkmenistan 2033.195161 1680.084848 1658.319719 1336.742661 1213.098551 1270.209388 1107.678001 1170.317080 1346.831339 1404.083552 ... 1872.954718 2055.839116 2329.525141 2441.216377 2632.427447 2981.136092 3269.666734 3557.001679 3873.768140 NaN
Turks and Caicos Islands NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Tuvalu 1835.690337 1877.143051 1944.693157 2135.338571 2019.903075 1891.902882 2073.544014 2385.731556 2338.402682 2304.642685 ... 2292.095972 2429.667970 2617.201598 2496.084645 2423.261486 2623.569044 2623.881334 2653.638130 NaN NaN
Uganda 203.525973 203.704571 213.691208 220.325701 238.230848 252.081995 257.141033 261.816302 274.431071 274.340830 ... 344.332237 360.963906 379.462920 393.617696 400.453446 424.949038 429.402939 429.227930 434.223099 NaN
Ukraine 2413.565227 2173.213267 1863.015630 1442.889816 1276.909572 1159.462439 1134.972663 1123.403778 1131.778443 1210.678891 ... 1975.514154 2144.339196 2205.569047 1887.505505 1974.610008 2084.770609 2094.108288 2098.882105 2081.044598 NaN
United Arab Emirates 46527.725984 45563.789512 43778.263932 44488.693086 45203.912352 45547.185676 46856.843155 44611.980071 43512.558957 45610.666361 ... 38363.007054 34059.706336 30613.283238 25976.648243 24423.523976 24428.130127 24948.699493 25992.176376 26792.504870 NaN
United Kingdom 28336.628971 28386.413331 29067.629253 30160.707655 30842.194049 31584.174362 32307.090163 33344.006956 34280.256729 35445.360061 ... 40848.277990 41567.277201 41104.473693 39036.231764 39471.731251 39808.693995 39793.393295 40199.316944 40967.698535 NaN
United States 32537.699274 33230.459156 33695.616711 34628.879700 35149.387482 36061.615329 37228.767279 38434.753167 39776.100559 40945.633967 ... 45052.921324 45420.187491 44861.390969 43235.558538 43961.168507 44324.944379 45008.614091 45660.733764 46405.259222 NaN
Uruguay 4070.778061 4361.895681 4444.982659 4733.712395 4631.620458 4854.994175 5232.968302 5434.352333 5301.297452 5180.320568 ... 5426.077865 5765.950272 6159.285387 6397.877786 6873.312262 7204.218838 7419.204610 7771.948054 8016.680636 NaN
Uzbekistan 532.939764 462.284708 441.504291 410.409699 399.433144 398.527562 411.421150 422.261022 435.696435 446.037963 ... 579.576154 625.665999 673.696613 716.080800 755.322265 796.350418 849.059692 902.773319 960.048048 NaN
Vanuatu 1848.478429 1841.872580 1802.611906 1913.247731 1886.345189 1890.202378 1946.788822 1995.522908 1966.078208 2040.738045 ... 1995.889863 2048.408726 2128.488900 2146.984363 2131.092886 2107.094816 2095.691890 2089.124126 NaN NaN
Venezuela, RB 5629.741565 5836.803961 5725.018664 5471.422571 5569.245133 5445.208077 5677.120652 5583.220237 5149.871490 5239.821714 ... 5873.313222 6283.685921 6510.387860 6204.395342 6019.880351 6179.257320 6433.632482 6429.204742 6088.075224 NaN
Vietnam 313.453423 334.546174 355.352565 380.318305 409.826497 440.991703 469.559115 489.061697 504.778570 531.858397 ... 740.055098 784.276205 819.916158 855.070048 900.493693 946.803418 986.013763 1028.628664 1077.909089 NaN
Virgin Islands (U.S.) NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
West Bank and Gaza NaN NaN NaN 879.607743 900.961888 924.121257 1095.845997 1345.218416 1546.899603 1358.873551 ... 1354.732178 1297.125425 1151.478443 1352.911484 1344.978811 1408.291834 1564.401466 1453.395379 1389.881437 NaN
Yemen, Rep. 664.401501 682.361349 673.895285 685.528801 694.354833 700.449157 713.870149 735.161508 741.998561 766.138663 ... 819.425322 823.090840 832.293179 842.861916 847.283175 700.354523 698.967525 709.469348 NaN NaN
Zambia 625.864451 599.570735 624.519311 556.466951 558.031705 577.212444 583.184788 565.264927 575.777102 582.624116 ... 726.114165 764.703143 800.527758 848.883534 908.747917 937.642189 970.765075 1004.714584 1032.802532 NaN
Zimbabwe 696.045420 618.541739 611.896826 655.576781 645.016709 700.186601 708.094156 718.580475 704.221091 675.798307 ... 423.219322 402.549347 326.568863 340.422901 372.287290 408.377273 441.916720 451.424191 455.102890 NaN

214 rows × 25 columns

In [19]:
df_internet
Out[19]:
1991 [YR1991] 1992 [YR1992] 1993 [YR1993] 1994 [YR1994] 1995 [YR1995] 1996 [YR1996] 1997 [YR1997] 1998 [YR1998] 1999 [YR1999] 2000 [YR2000] ... 2006 [YR2006] 2007 [YR2007] 2008 [YR2008] 2009 [YR2009] 2010 [YR2010] 2011 [YR2011] 2012 [YR2012] 2013 [YR2013] 2014 [YR2014] 2015 [YR2015]
Country Name
Afghanistan NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... 2.107124 1.900000 1.840000 3.550000 4.00 5.000000 5.454545 5.90000 6.39000 NaN
Albania NaN NaN NaN NaN 0.011169 0.032197 0.048594 0.065027 0.081437 0.114097 ... 9.609991 15.036115 23.860000 41.200000 45.00 49.000000 54.655959 57.20000 60.10000 NaN
Algeria NaN NaN NaN 0.000361 0.001769 0.001739 0.010268 0.020239 0.199524 0.491706 ... 7.375985 9.451191 10.180000 11.230000 12.50 14.000000 15.228027 16.50000 18.09000 NaN
American Samoa NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Andorra NaN NaN NaN NaN NaN 1.526601 3.050175 6.886209 7.635686 10.538836 ... 48.936847 70.870000 70.040000 78.530000 81.00 81.000000 86.434425 94.00000 95.90000 NaN
Angola NaN NaN NaN NaN NaN 0.000776 0.005674 0.018454 0.071964 0.105046 ... 1.907648 3.200000 4.600000 6.000000 10.00 14.776000 16.937210 19.10000 21.26000 NaN
Antigua and Barbuda NaN NaN NaN NaN 2.200769 2.858450 3.480537 4.071716 5.300681 6.482226 ... 30.000000 34.000000 38.000000 42.000000 47.00 52.000000 58.000000 63.40000 64.00000 NaN
Argentina NaN 0.002993 0.029527 0.043706 0.086277 0.141955 0.280340 0.830767 3.284482 7.038683 ... 20.927202 25.946633 28.112623 34.000000 45.00 51.000000 55.800000 59.90000 64.70000 NaN
Armenia NaN NaN NaN 0.009117 0.052743 0.094573 0.111651 0.128659 0.970738 1.300470 ... 5.631788 6.021253 6.210000 15.300000 25.00 32.000000 37.500000 41.90000 46.30000 NaN
Aruba NaN NaN NaN NaN NaN 2.768383 NaN NaN 4.506179 15.442823 ... 28.000000 30.900000 52.000000 58.000000 62.00 69.000000 74.000000 78.90000 83.78000 NaN
Australia 1.097204 1.768765 1.974611 2.232101 2.759655 3.275250 16.369358 30.813239 40.783784 46.756116 ... 66.000000 69.450000 71.670000 74.250000 76.00 79.487698 79.000000 83.00000 84.56000 NaN
Austria 0.259082 0.642818 0.765343 1.393423 1.890211 6.909162 9.533974 15.421219 23.044317 33.730133 ... 63.600000 69.370000 72.870000 73.450000 75.17 78.739993 80.029994 80.61880 81.00000 NaN
Azerbaijan NaN NaN NaN 0.001431 0.002056 0.006355 0.025188 0.037485 0.099229 0.147758 ... 11.992177 14.540000 17.080000 27.400000 46.00 50.000000 54.200000 58.70000 61.00000 NaN
Bahamas, The NaN NaN NaN NaN 0.960031 1.746951 1.362954 2.335591 3.764558 8.000000 ... 26.000000 27.000000 31.540000 33.880000 43.00 65.000000 71.748203 72.00000 76.92000 NaN
Bahrain NaN NaN NaN NaN 0.346206 0.843254 1.646299 3.218202 4.720358 6.153733 ... 28.243952 32.910000 51.950000 53.000000 55.00 76.999967 88.000000 90.00004 90.99998 NaN
Bangladesh NaN NaN NaN NaN NaN NaN 0.000751 0.003685 0.036170 0.071039 ... 1.000000 1.800000 2.500000 3.100000 3.70 4.500000 5.000000 6.63000 9.60000 NaN
Barbados NaN NaN NaN NaN 0.007752 0.389464 0.783429 1.970249 2.376247 3.973678 ... 55.300000 58.200000 61.400000 64.700000 65.10 67.000000 70.000000 73.00000 76.67000 NaN
Belarus NaN NaN NaN 0.000486 0.002921 0.029298 0.049021 0.073869 0.494881 1.860398 ... 16.200000 19.700000 23.000000 27.430000 31.80 39.648896 46.910000 54.17000 59.02000 NaN
Belgium 0.020073 0.100041 0.199446 0.695995 0.991663 2.968412 4.938081 7.886623 13.772214 29.431692 ... 59.720000 64.440000 66.000000 70.000000 75.00 81.609996 80.719991 82.17020 85.00000 NaN
Belize NaN NaN NaN NaN 0.045397 0.882807 1.288582 2.091516 4.076741 5.963835 ... 24.000000 24.600000 26.300000 27.200000 28.20 30.700000 31.000000 33.60000 38.70000 NaN
Benin NaN NaN NaN NaN NaN 0.001693 0.024649 0.047877 0.154907 0.225248 ... 1.537854 1.790000 1.850000 2.240000 3.13 4.148323 4.500000 4.90000 5.30000 NaN
Bermuda NaN NaN NaN NaN 6.838163 16.202466 24.189257 32.103759 39.947589 42.949860 ... 69.899655 74.350594 82.300000 83.250000 84.21 88.336000 91.299305 95.30000 96.80000 NaN
Bhutan NaN NaN NaN NaN NaN NaN NaN NaN 0.137572 0.400944 ... 4.518317 5.920000 6.550000 7.170000 13.60 21.000000 24.000000 29.90000 34.37000 NaN
Bolivia NaN NaN NaN NaN 0.066808 0.196081 0.447839 0.626484 0.981815 1.442764 ... 6.200671 10.499244 12.500000 16.800000 22.40 30.000000 35.340000 36.94000 39.02000 NaN
Bosnia and Herzegovina NaN NaN NaN NaN NaN 0.015126 0.059426 0.143671 0.194374 1.082961 ... 25.122386 27.920000 34.660000 37.740000 42.75 47.770000 52.780000 57.79000 60.80000 NaN
Botswana 0.000000 NaN NaN NaN 0.064521 0.157454 0.307747 0.602401 1.122391 2.902667 ... 4.289933 5.280000 6.250000 6.150000 6.00 8.000000 11.500000 15.00000 18.50000 NaN
Brazil 0.003288 0.012946 0.025498 0.037673 0.105138 0.450789 0.786079 1.477875 2.038732 2.870685 ... 28.178380 30.880000 33.830000 39.220000 40.65 45.690000 48.560000 51.04000 57.60000 NaN
Brunei Darussalam NaN NaN NaN NaN 1.017080 3.303350 4.831058 6.284743 7.671041 8.996285 ... 42.186349 44.680000 46.000000 49.000000 53.00 56.000000 60.273065 64.50000 68.77000 NaN
Bulgaria NaN NaN 0.002339 0.019527 0.119666 0.725251 1.219813 1.844965 2.908154 5.370923 ... 27.090000 33.640000 39.670000 45.000000 46.23 47.979993 51.899988 53.06150 55.49000 NaN
Burkina Faso NaN NaN NaN NaN NaN 0.000961 0.018686 0.045423 0.061780 0.077080 ... 0.632708 0.750000 0.920000 1.130000 2.40 3.000000 3.725035 9.10000 9.40000 NaN
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
Sweden 1.160519 1.497871 1.716364 3.412810 5.098024 9.043600 23.727948 33.467512 41.432783 45.687652 ... 87.760000 82.010000 90.000000 91.000000 90.00 92.769986 93.179988 94.78360 92.52000 NaN
Switzerland 1.179956 1.751713 2.167270 2.720004 3.552007 4.549657 15.100000 24.800000 34.000000 47.100000 ... 75.700000 77.200000 79.200000 81.300000 83.90 85.193028 85.200000 86.34000 87.00000 NaN
Syrian Arab Republic 0.000000 0.000000 0.000000 0.000000 0.000000 0.000000 0.032608 0.063687 0.124295 0.181699 ... 7.832552 11.500000 14.000000 17.300000 20.70 22.500000 24.300100 26.20000 28.09000 NaN
Tajikistan NaN NaN NaN NaN NaN NaN NaN NaN 0.032792 0.048600 ... 3.772406 7.197620 8.780000 10.070000 11.55 13.030000 14.510000 16.00000 17.49000 NaN
Tanzania NaN NaN NaN NaN NaN 0.001622 0.007900 0.009244 0.075131 0.117194 ... 1.300000 1.600000 1.900000 2.400000 2.90 3.200000 3.950000 4.40000 4.86000 NaN
Thailand 0.000052 0.000344 0.013581 0.038614 0.074825 0.115472 0.360522 1.091219 2.426242 3.689041 ... 17.160715 20.030000 18.200000 20.100000 22.40 23.669926 26.460000 28.94000 34.89000 NaN
Timor-Leste NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... 0.116628 0.140959 0.163877 0.185252 0.21 0.900000 0.914700 1.10000 1.14000 NaN
Togo 0.000000 0.000000 0.000000 0.000000 0.000000 0.010929 0.211139 0.305584 0.590363 0.800000 ... 2.000000 2.200000 2.400000 2.600000 3.00 3.500000 4.000000 4.50000 5.70000 NaN
Tonga NaN NaN NaN NaN 0.123231 0.163793 0.510866 0.765134 1.017967 2.434398 ... 5.853944 7.179865 8.110770 10.000000 16.00 25.000000 33.000000 35.00000 40.00000 NaN
Trinidad and Tobago NaN NaN NaN NaN 0.158150 0.393081 1.173175 2.724825 5.814251 7.721411 ... 30.003749 32.300000 34.800000 44.300000 48.50 55.200000 59.516200 63.80000 65.10000 NaN
Tunisia NaN NaN NaN 0.007380 0.011192 0.027615 0.043657 0.107941 1.602495 2.750740 ... 12.986409 17.100000 27.530000 34.070000 36.80 39.100000 41.441600 43.80000 46.16000 NaN
Turkey NaN NaN 0.008458 0.049869 0.081691 0.192725 0.473695 0.698805 2.292118 3.761685 ... 18.240000 28.630000 34.370000 36.400000 39.82 43.065710 45.130000 46.25000 51.04000 NaN
Turkmenistan NaN NaN NaN NaN NaN NaN NaN NaN 0.045021 0.133282 ... 1.319573 1.406361 1.750000 1.950000 3.00 5.000000 7.195800 9.60000 12.20000 NaN
Turks and Caicos Islands NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN
Tuvalu NaN NaN NaN NaN NaN NaN NaN NaN NaN 5.241640 ... NaN 10.000000 15.000000 20.000000 25.00 30.000000 35.000000 37.00000 NaN NaN
Uganda NaN NaN NaN NaN 0.002863 0.004626 0.010319 0.065289 0.105544 0.163714 ... 2.529363 3.671965 7.900000 9.780000 12.50 13.013543 14.689600 16.20000 17.71000 NaN
Ukraine NaN NaN 0.000777 0.013641 0.043084 0.098580 0.198822 0.301076 0.405385 0.716184 ... 4.506125 6.550000 11.000000 17.900000 23.30 28.708263 35.270000 41.00000 43.40000 NaN
United Arab Emirates NaN NaN NaN NaN 0.102939 0.375394 3.295593 6.908303 14.942699 23.625301 ... 52.000000 61.000000 63.000000 64.000000 68.00 78.000000 84.999992 88.00000 90.40000 NaN
United Kingdom 0.174231 0.260615 0.519762 1.036609 1.895168 4.123650 7.385399 13.669983 21.293638 26.821754 ... 68.820000 75.090000 78.390000 83.560000 85.00 85.379999 87.479998 89.84410 91.61000 NaN
United States 1.163194 1.724203 2.271673 4.862781 9.237088 16.419353 21.616401 30.093197 35.848724 43.079163 ... 68.931193 75.000000 74.000000 71.000000 71.69 69.729461 79.300000 84.20000 87.36000 NaN
Uruguay NaN NaN NaN 0.062474 0.310129 1.847472 3.363240 6.987069 9.972765 10.539058 ... 29.400000 34.000000 39.300000 41.800000 46.40 51.404661 54.453769 57.69000 61.46000 NaN
Uzbekistan NaN NaN NaN NaN 0.001527 0.004285 0.010537 0.020754 0.030688 0.484347 ... 6.388322 7.490605 9.080115 17.058216 20.00 30.200000 36.521300 38.20000 43.55000 NaN
Vanuatu NaN NaN NaN NaN NaN 0.056846 0.139506 0.274186 0.538300 2.108337 ... 5.850585 6.800000 7.269120 7.500000 8.00 9.200000 10.598000 11.30000 18.80000 NaN
Venezuela, RB NaN 0.012082 0.041587 0.055487 0.122215 0.248261 0.390959 1.383990 2.839826 3.359597 ... 15.224711 20.830000 25.880000 32.700000 37.37 40.220000 49.050083 54.90000 57.00000 NaN
Vietnam NaN NaN NaN NaN NaN 0.000135 0.003982 0.013079 0.128927 0.254248 ... 17.254562 20.755445 23.920000 26.550000 30.65 35.070000 39.490000 43.90000 48.31000 NaN
Virgin Islands (U.S.) NaN NaN NaN 0.940645 2.801958 4.647186 6.948369 9.245220 11.074606 13.815081 ... 27.332611 27.339336 27.361777 27.396510 31.22 35.600000 40.547900 45.30000 50.07000 NaN
West Bank and Gaza NaN NaN NaN NaN NaN NaN NaN NaN NaN 1.111306 ... 18.410000 21.176000 24.358000 32.230000 37.40 41.080000 43.400000 46.60000 53.67000 NaN
Yemen, Rep. NaN NaN NaN NaN NaN 0.000621 0.015025 0.023323 0.056629 0.082500 ... 1.247824 5.010000 6.890000 9.960000 12.35 14.905000 17.446500 20.00000 22.55000 NaN
Zambia NaN NaN NaN 0.006776 0.008784 0.009069 0.009330 0.030226 0.147053 0.191072 ... 4.159913 4.870000 5.550000 6.310000 10.00 11.500000 13.468200 15.40000 17.34000 NaN
Zimbabwe NaN NaN NaN 0.001739 0.007684 0.016790 0.033080 0.081648 0.161676 0.401434 ... 9.791842 10.850000 11.400000 11.360000 11.50 15.700000 17.090000 18.50000 19.89000 NaN

214 rows × 25 columns

Plotting this with Bokeh

We follow the gapminder example. We need to setup the data sources for the Bokeh plot and then draw it.

Setting up the data sources

In [20]:
from bokeh.models import ColumnDataSource
In [21]:
POP_SCALING = lambda x:  np.sqrt(x / np.pi) / 200

years = df_pop.columns

year_label = lambda year: "_" + year.split()[0]

sources = {}

for year in years:
    population = POP_SCALING(df_pop[year])
    population.name = 'population' 
    
    internet = df_internet[year]
    internet.name = 'internet users'

    gdp = df_gdp[year]
    gdp.name = 'gdp (2005 $)'
    
    new_df = pd.concat([internet, gdp, population], axis=1)
    new_df.index.name = 'country'
    sources[year_label(year)] = ColumnDataSource(new_df)
In [22]:
sources
Out[22]:
{'_1991': <bokeh.models.sources.ColumnDataSource at 0x8ec5860>,
 '_1992': <bokeh.models.sources.ColumnDataSource at 0x8ec5cf8>,
 '_1993': <bokeh.models.sources.ColumnDataSource at 0x8ec5eb8>,
 '_1994': <bokeh.models.sources.ColumnDataSource at 0x8ec5e80>,
 '_1995': <bokeh.models.sources.ColumnDataSource at 0x8ec5be0>,
 '_1996': <bokeh.models.sources.ColumnDataSource at 0x8ec5e48>,
 '_1997': <bokeh.models.sources.ColumnDataSource at 0x8ec5a90>,
 '_1998': <bokeh.models.sources.ColumnDataSource at 0x8ed4978>,
 '_1999': <bokeh.models.sources.ColumnDataSource at 0x8ed4ba8>,
 '_2000': <bokeh.models.sources.ColumnDataSource at 0x8ed4dd8>,
 '_2001': <bokeh.models.sources.ColumnDataSource at 0x8ed4a20>,
 '_2002': <bokeh.models.sources.ColumnDataSource at 0x8ec5dd8>,
 '_2003': <bokeh.models.sources.ColumnDataSource at 0x8ec5da0>,
 '_2004': <bokeh.models.sources.ColumnDataSource at 0x8ec58d0>,
 '_2005': <bokeh.models.sources.ColumnDataSource at 0x8ed45c0>,
 '_2006': <bokeh.models.sources.ColumnDataSource at 0x8ed4048>,
 '_2007': <bokeh.models.sources.ColumnDataSource at 0x8ec5d30>,
 '_2008': <bokeh.models.sources.ColumnDataSource at 0x8ed4518>,
 '_2009': <bokeh.models.sources.ColumnDataSource at 0x8f0c7f0>,
 '_2010': <bokeh.models.sources.ColumnDataSource at 0x8f0c9b0>,
 '_2011': <bokeh.models.sources.ColumnDataSource at 0x8f0cb70>,
 '_2012': <bokeh.models.sources.ColumnDataSource at 0x8f0cd30>,
 '_2013': <bokeh.models.sources.ColumnDataSource at 0x8f0cf60>,
 '_2014': <bokeh.models.sources.ColumnDataSource at 0x8f0cb00>,
 '_2015': <bokeh.models.sources.ColumnDataSource at 0x8ed49b0>}

Let's inspect one of these sources:

In [23]:
src = sources['_1991']
In [24]:
src.column_names
Out[24]:
['gdp (2005 $)', 'population', 'internet users', 'country']

Let's build the dict that references the datasources:

In [25]:
year_int = lambda year: int(year.split()[0])
dictionary_of_sources = dict(zip([year_int(year) for year in years], [year_label(year) for year in years]))
js_source_array = str(dictionary_of_sources).replace("'", "")
In [26]:
js_source_array
Out[26]:
'{1991: _1991, 1992: _1992, 1993: _1993, 1994: _1994, 1995: _1995, 1996: _1996, 1997: _1997, 1998: _1998, 1999: _1999, 2000: _2000, 2001: _2001, 2002: _2002, 2003: _2003, 2004: _2004, 2005: _2005, 2006: _2006, 2007: _2007, 2008: _2008, 2009: _2009, 2010: _2010, 2011: _2011, 2012: _2012, 2013: _2013, 2014: _2014, 2015: _2015}'

Setting up the plot

In [27]:
import bokeh.plotting as bp
bp.output_notebook()
Loading BokehJS ...

Axes

First, we setup the axes.

In [28]:
from bokeh.models import Range1d, Plot, LinearAxis, SingleIntervalTicker
In [44]:
# Set up the plot
xdr = Range1d(1, 60000)
ydr = Range1d(-10, 110)
plot = Plot(
    x_range=xdr,
    y_range=ydr,
    title="",
    plot_width=800,
    plot_height=400,
    outline_line_color=None,
    toolbar_location=None,    
)
AXIS_FORMATS = dict(
    minor_tick_in=None,
    minor_tick_out=None,
    major_tick_in=None,
    major_label_text_font_size="10pt",
    major_label_text_font_style="normal",
    axis_label_text_font_size="10pt",

    axis_line_color='#AAAAAA',
    major_tick_line_color='#AAAAAA',
    major_label_text_color='#666666',

    major_tick_line_cap="round",
    axis_line_cap="round",
    axis_line_width=1,
    major_tick_line_width=1,
)

xaxis = LinearAxis(ticker=SingleIntervalTicker(interval=10000), axis_label="Gdp (2005 $)", **AXIS_FORMATS)
yaxis = LinearAxis(ticker=SingleIntervalTicker(interval=10), axis_label="Internet usage (per 100 people)", **AXIS_FORMATS)   
plot.add_layout(xaxis, 'below')
plot.add_layout(yaxis, 'left')

Let's have a look at the current format of the plot we are building:

In [45]:
bp.show(plot)
Out[45]:

<Bokeh Notebook handle for In[45]>

Background text with the year

Let's now add the background text:

In [46]:
from bokeh.models import Text
In [48]:
# Add the year in background (add before circle)
text_source = ColumnDataSource({'year': [str(year_int(year)) for year in years[:1]]})
text = Text(x=(xdr.end + xdr.start) / 10, y=20, text='year', text_font_size='150pt', text_color='#EEEEEE')
plot.add_glyph(text_source, text)
Out[48]:
<bokeh.models.renderers.GlyphRenderer at 0x61a7b38>

Let's look at our plot in its current form:

In [49]:
bp.show(plot)
Out[49]:

<Bokeh Notebook handle for In[49]>

Bubbles and hover

Our plot is now missing two things: the renderer for the bubbles representing the country size as well as the hover tool that allows to identify the country when the mouse is hovering over a bubble.

In [61]:
from bokeh.models import Circle, HoverTool
In [62]:
# Add the circle glyphs
renderer_source = sources[year_label(years[0])]
circle_glyph = Circle(
    x='gdp (2005 $)', y='internet users', size='population',
    fill_color='#7c7e71', fill_alpha=0.8, 
    line_color='#7c7e71', line_width=0.5, line_alpha=0.5)
circle_renderer = plot.add_glyph(renderer_source, circle_glyph)

# Add the hover (only against the circle and not other plot elements)
tooltips = "@country"
plot.add_tools(HoverTool(tooltips=tooltips, renderers=[circle_renderer]))

Let's inspect some properties of this:

In [52]:
renderer_source.column_names
Out[52]:
['gdp (2005 $)', 'population', 'internet users', 'country']

Again, let's check our plot:

In [53]:
bp.show(plot)
Out[53]:

<Bokeh Notebook handle for In[53]>

Making it interactive using a slider and final plot

This is the tricky part of this plot: it uses Javascript to change the data source of the plot dynamically.

In [54]:
from bokeh.models import CustomJS, Slider
In [55]:
years_label = [year_int(year) for year in years]
In [56]:
# Add the slider
code = """
    var year = slider.get('value'),
        sources = %s,
        new_source_data = sources[year].get('data');
    renderer_source.set('data', new_source_data);
    text_source.set('data', {'year': [String(year)]});
""" % js_source_array

callback = CustomJS(args=sources, code=code)
slider = Slider(start=years_label[0], end=years_label[-1], value=1, step=1, title="Year", callback=callback, name='testy')
callback.args["renderer_source"] = renderer_source
callback.args["slider"] = slider
callback.args["text_source"] = text_source

Finally let's plot the result by putting the slider on the bottom of the plot.

In [57]:
from bokeh.plotting import vplot
from bokeh.resources import JSResources
In [60]:
# Stick the plot and the slider together
layout = vplot(plot, slider, )
bp.show(layout)
Out[60]:

<Bokeh Notebook handle for In[60]>

Discussion

In the end, I've managed to replicate the interactive plot that can be found on Ramiro's website. I've succeeded to integrate a slider that, in my opionion, allows better visualization of the passing of time. However, I'm not sure to what insight this plot leads. I guess it allows to visualize the dramatic deployment of internet usage since the 1990's.

This post was entirely written using the IPython notebook. Its content is BSD-licensed. You can see a static view or download this notebook with the help of nbviewer at 20160526_InternetUsersBokeh.ipynb.

Comments