{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Why worry?\n", "\n", "From PWC's [Low Carbon Economy Index 2018](https://www.pwc.co.uk/services/sustainability-climate-change/insights/low-carbon-economy-index.html):\n", "> Carbon intensity continued to fall at a rate consistent with the previous few years, at 2.6%. But even this falls short of the 3% average decarbonisation rate needed to meet the weak national targets pledged in the 2015 Paris Agreement. The gap between the current decarbonisation rate and that needed to limit global warming to two degrees is widening. It’s now 6.4% per year for the rest of this century.\n", "\n", "> In contrast with our report last year, not one of the G20 countries achieved the 6.4% rate required to limit warming to two degrees this year. That goal is slipping further out of reach – at current levels of decarbonisation, the global carbon budget for two degrees will run out in 2036.\n", "\n", "Not sure we are on the right track! But maybe you want to check by yourself.\n", "\n", "In this notebook, we access publicly available data from the [World Bank](https://www.worldbank.org), and vizualise the evolution of greenhouse gas emissions, as well as that of the much related gross domestic product." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# World Bank data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The [World Bank](https://www.worldbank.org/) offers a wide set of economic and developement indicators. We download the values for a few of these indicators using `wbdata`, reshape the data using `pandas`, and explore the metrics using `ploty` and `ipywidgets`." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "lines_to_end_of_cell_marker": 2 }, "outputs": [], "source": [ "import os\n", "import pandas as pd\n", "import wbdata as wb\n", "\n", "# My preferences for printing DataFrames: few rows, and many columns.\n", "pd.options.display.max_rows = 6\n", "pd.options.display.max_columns = 20\n", "\n", "\n", "# Download just once the desired indicators, save to a file\n", "def download_once(indicators, path):\n", " if os.path.isfile(path):\n", " return pd.read_hdf(path, 'indicators')\n", "\n", " data = wb.get_dataframe(indicators, convert_date=True).sort_index()\n", " data.to_hdf(path, 'indicators')\n", "\n", " return data" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The names of the indicators below were found using the World Bank indicator [search page](https://data.worldbank.org/indicator). There are actually many more indicators there!" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "indicators = {\n", " 'SP.POP.TOTL': 'Population, total',\n", " 'AG.SRF.TOTL.K2': 'Surface area (sq. km)',\n", " 'AG.LND.TOTL.K2': 'Land area (sq. km)',\n", " 'AG.LND.ARBL.ZS': 'Arable land (% of land area)',\n", " 'EN.ATM.GHGT.KT.CE': 'Total greenhouse gas emissions (kt of CO2 equivalent)',\n", " 'EN.ATM.CO2E.KT': 'CO2 emissions (kt)',\n", " 'EN.ATM.NOXE.KT.CE': 'Nitrous oxide emissions (thousand metric tons of CO2 equivalent)',\n", " 'EN.ATM.METH.KT.CE': 'Methane emissions (kt of CO2 equivalent)',\n", " 'EN.ATM.CO2E.SF.KT': 'CO2 emissions from solid fuel consumption (kt)',\n", " 'EN.ATM.CO2E.LF.KT': 'CO2 emissions from liquid fuel consumption (kt)',\n", " 'EN.ATM.CO2E.GF.KT': 'CO2 emissions from gaseous fuel consumption (kt)',\n", " 'EN.CO2.MANF.ZS': 'CO2 emissions from manufacturing industries and construction (% of total fuel combustion)',\n", " 'EN.CO2.TRAN.ZS': 'CO2 emissions from transport (% of total fuel combustion)',\n", " 'EN.ATM.CO2E.GF.ZS': 'CO2 emissions from gaseous fuel consumption (% of total)',\n", " 'EN.ATM.CO2E.KD.GD': 'CO2 emissions (kg per 2010 US$ of GDP)',\n", " 'AG.YLD.CREL.KG': 'Cereal yield (kg per hectare)',\n", " 'AG.PRD.LVSK.XD': 'Livestock production index (2004-2006 = 100)',\n", " 'AG.PRD.CROP.XD': 'Crop production index (2004-2006 = 100)',\n", " 'NY.GDP.MKTP.CD': 'GDP (current US$)',\n", " 'NY.GDP.MKTP.KD': 'GDP (constant 2010 US$)'}" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "world_bank_data = download_once(indicators, 'world_bank_indicators.hdf')" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "lines_to_next_cell": 2 }, "outputs": [ { "data": { "text/html": [ "
\n", " | Population, total | \n", "Surface area (sq. km) | \n", "Land area (sq. km) | \n", "Arable land (% of land area) | \n", "Total greenhouse gas emissions (kt of CO2 equivalent) | \n", "CO2 emissions (kt) | \n", "Nitrous oxide emissions (thousand metric tons of CO2 equivalent) | \n", "Methane emissions (kt of CO2 equivalent) | \n", "CO2 emissions from solid fuel consumption (kt) | \n", "CO2 emissions from liquid fuel consumption (kt) | \n", "CO2 emissions from gaseous fuel consumption (kt) | \n", "CO2 emissions from manufacturing industries and construction (% of total fuel combustion) | \n", "CO2 emissions from transport (% of total fuel combustion) | \n", "CO2 emissions from gaseous fuel consumption (% of total) | \n", "CO2 emissions (kg per 2010 US$ of GDP) | \n", "Cereal yield (kg per hectare) | \n", "Livestock production index (2004-2006 = 100) | \n", "Crop production index (2004-2006 = 100) | \n", "GDP (current US$) | \n", "GDP (constant 2010 US$) | \n", "
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
date | \n", "\n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " | \n", " |
1960-01-01 | \n", "3.032160e+09 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "9396705.835 | \n", "NaN | \n", "NaN | \n", "5148390.993 | \n", "3112685.279 | \n", "832409.0 | \n", "29.303831 | \n", "19.172690 | \n", "8.858519 | \n", "0.838262 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "1.365887e+12 | \n", "1.120951e+13 | \n", "
1961-01-01 | \n", "3.073369e+09 | \n", "134043190.4 | \n", "129721455.4 | \n", "9.693086 | \n", "NaN | \n", "9434402.595 | \n", "NaN | \n", "NaN | \n", "4922313.109 | \n", "3314109.922 | \n", "880080.0 | \n", "28.667935 | \n", "19.413947 | \n", "9.328413 | \n", "0.806609 | \n", "1421.619389 | \n", "33.027201 | \n", "32.483194 | \n", "1.420995e+12 | \n", "1.169612e+13 | \n", "
1962-01-01 | \n", "3.126510e+09 | \n", "134043190.4 | \n", "129721435.4 | \n", "9.726105 | \n", "NaN | \n", "9818839.874 | \n", "NaN | \n", "NaN | \n", "4925760.089 | \n", "3592479.226 | \n", "964421.0 | \n", "27.804382 | \n", "19.340737 | \n", "9.822148 | \n", "0.795196 | \n", "1510.863259 | \n", "33.868236 | \n", "33.771017 | \n", "1.526067e+12 | \n", "1.234743e+13 | \n", "
... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "... | \n", "
2015-01-01 | \n", "7.357559e+09 | \n", "134325130.2 | \n", "129732901.8 | \n", "10.991288 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "3923.219588 | \n", "NaN | \n", "NaN | \n", "7.484273e+13 | \n", "7.573359e+13 | \n", "
2016-01-01 | \n", "7.444157e+09 | \n", "134325130.2 | \n", "129733172.7 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "3966.779315 | \n", "NaN | \n", "NaN | \n", "7.593681e+13 | \n", "7.763127e+13 | \n", "
2017-01-01 | \n", "7.530360e+09 | \n", "134325130.2 | \n", "129733172.7 | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "NaN | \n", "8.068379e+13 | \n", "8.007783e+13 | \n", "
58 rows × 20 columns
\n", "