{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# A quick insight at world population\n", "\n", "## Collecting population data\n", "\n", "In the below we retrieve population data from the\n", "[World Bank](http://www.worldbank.org/)\n", "using the [wbdata](https://github.com/OliverSherouse/wbdata) python package" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import pandas as pd\n", "import wbdata as wb\n", "\n", "pd.options.display.max_rows = 6\n", "pd.options.display.max_columns = 20" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Corresponding indicator is found using search method - or, directly,\n", "the World Bank site." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "SP.POP.TOTL\tPopulation, total\n" ] } ], "source": [ "wb.search_indicators('Population, total') # SP.POP.TOTL\n", "# wb.search_indicators('area')\n", "# => https://data.worldbank.org/indicator is easier to use" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Now we download the population data" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [ { "data": { "text/html": [ "
\n", " | \n", " | Population, total | \n", "Surface area (sq. km) | \n", "Land area (sq. km) | \n", "Arable land (% of land area) | \n", "
---|---|---|---|---|---|
country | \n", "date | \n", "\n", " | \n", " | \n", " | \n", " |
Afghanistan | \n", "1960-01-01 | \n", "8996351.0 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
1961-01-01 | \n", "9166764.0 | \n", "652860.0 | \n", "652860.0 | \n", "11.717673 | \n", "|
1962-01-01 | \n", "9345868.0 | \n", "652860.0 | \n", "652860.0 | \n", "11.794259 | \n", "|
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
Zimbabwe | \n", "2015-01-01 | \n", "15777451.0 | \n", "390760.0 | \n", "386850.0 | \n", "10.339925 | \n", "
2016-01-01 | \n", "16150362.0 | \n", "390760.0 | \n", "386850.0 | \n", "NaN | \n", "|
2017-01-01 | \n", "16529904.0 | \n", "390760.0 | \n", "386850.0 | \n", "NaN | \n", "
15312 rows × 4 columns
\n", "\n", " | Population, total | \n", "Surface area (sq. km) | \n", "Land area (sq. km) | \n", "Arable land (% of land area) | \n", "
---|---|---|---|---|
date | \n", "\n", " | \n", " | \n", " | \n", " |
1960-01-01 | \n", "3.032160e+09 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "
1961-01-01 | \n", "3.073369e+09 | \n", "134043190.4 | \n", "129721455.4 | \n", "9.693086 | \n", "
1962-01-01 | \n", "3.126510e+09 | \n", "134043190.4 | \n", "129721435.4 | \n", "9.726105 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
2015-01-01 | \n", "7.357559e+09 | \n", "134325130.2 | \n", "129732901.8 | \n", "10.991288 | \n", "
2016-01-01 | \n", "7.444157e+09 | \n", "134325130.2 | \n", "129733172.7 | \n", "NaN | \n", "
2017-01-01 | \n", "7.530360e+09 | \n", "134325130.2 | \n", "129733172.7 | \n", "NaN | \n", "
58 rows × 4 columns
\n", "