Snapshot: Worldwide Energy Usage and Capacity

This project focuses on data obtained from the 2016 BP Statistical Review of World Energy, which looks at energy usage worldwide with data up to 2015.

Outline

Note: This notebook requires internet access to run.

This notebook was created by Stefany Gutu in May 2017 for the NYU Stern course Data Bootcamp.

Introduction

In the face of climate change and the current political atmosphere, it is more important than ever to know where our energy comes from. Moreover, we should have an idea of the capacity for transitioning to cleaner sources to secure future energy stability. In this document we take a look at trends in the following six regions: North America, South America, Africa, Middle East, Asia Pacific, and Europe/Eurasia. The conclusions drawn from the following data are based only on the graphics and a basic knowledge of energy patterns today.

Packages


In [106]:
import sys                                      # system module
import pandas as pd                             # data package
import math                                     # complex math functions
import matplotlib.pyplot as plt                 # graphics module  
import datetime as dt                           # date and time module
import numpy as np                              # foundation for Pandas
from pandas_datareader import wb, data as web   # worldbank data

# plotly imports
from plotly.offline import iplot, iplot_mpl     # plotting functions
import plotly.graph_objs as go                  # ditto
import plotly                                   # just to print version and init notebook
import cufflinks as cf                          # gives us df.iplot that feels like df.plot
cf.set_config_file(offline=True, offline_show_link=False)

# these lines make our graphics show up in the notebook
%matplotlib inline             
plotly.offline.init_notebook_mode(connected=True)

# check versions
print('Python version:', sys.version)
print('Pandas version:', pd.__version__)
print('Plotly version:', plotly.__version__)
print('Today:', dt.date.today(), '\n')
print('Stefany Gutu')


Python version: 3.5.2 |Anaconda custom (x86_64)| (default, Jul  2 2016, 17:52:12) 
[GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)]
Pandas version: 0.18.1
Plotly version: 2.0.7
Today: 2017-05-12 

Stefany Gutu

Import Data


In [107]:
url1 = 'http://www.bp.com/content/dam/bp/excel/energy-economics/statistical-review-2016'
url2 = '/bp-statistical-review-of-world-energy-2016-workbook.xlsx'
url = url1 + url2
bp = pd.read_excel(url)

Fossil Fuels

Emissions


In [130]:
# carbon dioxide emissions by region since 1965
# clean up and shape 
# only interested in 2015 so as to compare to renewable energy capacity at the end
# units = million tonnes carbon dioxide

emissions = pd.read_excel(url, 
                            sheetname='Carbon Dioxide Emissions',
                            index_col=0,
                            skiprows=2)

emissions = emissions.drop(
    emissions.columns[0:50], axis=1).drop(
    emissions.columns[51:53], axis=1)   # only 2015

emissions = emissions.ix[['Total North America', 'Total S. & Cent. America', 'Total Africa', 
                          'Total Middle East', 'Total Asia Pacific', 'Total Europe & Eurasia']]

emissions.index = ['North America', 'South America', 'Africa',
                   'Middle East', 'Asia Pacific', 'Europe/Eurasia']

emissions = emissions.astype(int).round()

emissions


Out[130]:
2015
North America 6492
South America 1376
Africa 1201
Middle East 2167
Asia Pacific 16066
Europe/Eurasia 6202

In [131]:
# plot total emissions by region in 2015

fig = {'data': [{
            'values': [6492, 1376, 1201, 2167, 16066, 6202], 
            'labels': ['North America', 'South America', 'Africa',
                       'Middle East', 'Asia Pacific', 'Europe/Eurasia'],     
            'marker': {'colors': ['rgb(205,92,92)', 'rgb(255,127,80)', 'rgb(255,215,0)', 
                       'rgb(147,112,219)', 'rgb(143,188,143)', 'rgb(100,149,237)']}, 
            'domain': {'x': [.2, .8]},
            'hoverinfo': 'label+percent',
            'hole': .3,
            'type': 'pie'}],
       'layout': {
        'legend':{
            'x':'-.01',
            'y':'-.07',
            'orientation':'h'},
        'annotations': [{
                'font': {
                    'size': 17},
                'showarrow': False,
                'text': '2015 CO2</br>Emissions</br>by Region',
                'x': '0.5',
                'y': '0.5'}]}}

iplot(fig)


The burning of coal, oil, and natural gas contributes to more than half of total carbon dioxide emissions worldwide (a fact not pictured above). This graphic takes a look at percentages rather than integer estimates as the purpose of this document already presupposes that emissions are too high and we must change our patterns. Instead we are interested which regions pollute most. It is scary to see in this graphic that Asia emitted almost half of the world's 2015 emissions (though this may not necessarily be only from fossil fuels). North America and Europe/Eurasia combined do not equal the impact of Asia Pacific, nor do the Middle East, South America, and Africa equal North America or Europe.

Consumption


In [110]:
# oil consumption by region since 1965
# clean up and shape 
# units = million tonnes

oil_cons = pd.read_excel(url, sheetname='Oil Consumption – Tonnes',
                         index_col=0,
                         skiprows=2)

oil_cons = oil_cons.drop(['2014.1','of total'], axis=1)

oil_cons = oil_cons.ix[['Total North America', 'Total S. & Cent. America', 'Total Africa', 
                      'Total Middle East', 'Total Asia Pacific', 'Total Europe & Eurasia']]

oil_cons.index = ['North America', 'South America', 'Africa',
                 'Middle East', 'Asia Pacific', 'Europe/Eurasia']

oil_cons = oil_cons.astype(int).round()   # convert to integer and round up 

oil_cons = oil_cons.T

oil_cons.head()


Out[110]:
North America South America Africa Middle East Asia Pacific Europe/Eurasia
1965 619 80 27 44 163 589
1966 650 85 30 45 188 642
1967 677 87 29 46 219 697
1968 724 93 31 48 251 760
1969 763 98 31 50 292 837

In [111]:
# natural gas consumption by region since 1965
# clean up and shape 
# units = million tonnes oil equivalent

gas_cons = pd.read_excel(url, 
                         sheetname='Gas Consumption – tonnes',
                         index_col=0,
                         skiprows=2)

gas_cons = gas_cons.drop(['2014.1','of total'], axis=1)

gas_cons = gas_cons.ix[['Total North America', 'Total S. & Cent. America', 'Total Africa', 
                      'Total Middle East', 'Total Asia Pacific', 'Total Europe & Eurasia']]

gas_cons.index = ['North America', 'South America', 'Africa',
                 'Middle East', 'Asia Pacific', 'Europe/Eurasia']

gas_cons = gas_cons.astype(int).round()   # convert to integer and round up 

gas_cons = gas_cons.T

gas_cons.head()


Out[111]:
North America South America Africa Middle East Asia Pacific Europe/Eurasia
1965 425 12 0 3 5 139
1966 458 13 1 3 5 156
1967 482 14 1 4 6 175
1968 517 15 1 5 7 198
1969 559 15 1 6 9 225

In [112]:
# coal consumption by region since 1965
# clean up and shape 
# units = million tonnes oil equivalent

coal_cons = pd.read_excel(url, 
                          sheetname='Coal Consumption -  Mtoe',
                          index_col=0,
                          skiprows=2)

coal_cons = coal_cons.drop(['2014.1','of total'], axis=1)

coal_cons = coal_cons.ix[['Total North America', 'Total S. & Cent. America', 'Total Africa', 
                      'Total Middle East', 'Total Asia Pacific', 'Total Europe & Eurasia']]

coal_cons.index = ['North America', 'South America', 'Africa',
                 'Middle East', 'Asia Pacific', 'Europe/Eurasia']

coal_cons = coal_cons.astype(int).round()   # convert to integer and round up 

coal_cons = coal_cons.T

coal_cons.head()


Out[112]:
North America South America Africa Middle East Asia Pacific Europe/Eurasia
1965 307 5 28 0 237 821
1966 321 6 27 0 250 811
1967 316 6 28 0 243 799
1968 328 5 29 0 247 804
1969 328 6 30 0 277 816

In [113]:
# find maximum y value for plot

oil_cons.max()


Out[113]:
North America     1129
South America      329
Africa             182
Middle East        425
Asia Pacific      1501
Europe/Eurasia    1236
dtype: int64

In [114]:
# find maximum y value for plot

gas_cons.max()


Out[114]:
North America      880
South America      157
Africa             121
Middle East        441
Asia Pacific       631
Europe/Eurasia    1019
dtype: int64

In [115]:
coal_cons.max()


Out[115]:
North America      616
South America       37
Africa             102
Middle East         12
Asia Pacific      2798
Europe/Eurasia     874
dtype: int64

In [116]:
# plot oil, natural gas, and coal consumption by region since 1965
# max = 2798 - coal, Asia Pacific

trace1 = dict(type='scatter',
              x=oil_cons.index,
              y=oil_cons['North America'],
              mode='lines',
              marker={'color':'rgb(205,92,92)'},
              name='North America')

trace2 = dict(type='scatter',
              x=oil_cons.index,
              y=oil_cons['South America'],
              mode='lines',
              marker={'color':'rgb(255,127,80)'},
              name='South America')

trace3 = dict(type='scatter',
              x=oil_cons.index,
              y=oil_cons['Africa'],
              mode='lines',
              marker={'color':'rgb(255,215,0)'},
              name='Africa')

trace4 = dict(type='scatter',
              x=oil_cons.index,
              y=oil_cons['Middle East'],
              mode='lines',
              marker={'color':'rgb(147,112,219)'},
              name='Middle East')

trace5 = dict(type='scatter',
              x=oil_cons.index,
              y=oil_cons['Asia Pacific'],
              mode='lines',
              marker={'color':'rgb(143,188,143)'},
              name='Asia Pacific')

trace6 = dict(type='scatter',
              x=oil_cons.index,
              y=oil_cons['Europe/Eurasia'],
              mode='lines',
              marker={'color':'rgb(100,149,237)'},
              name='Europe/Eurasia')

trace7 = dict(type='scatter',
              x=gas_cons.index,
              y=gas_cons['North America'],
              mode='lines',
              marker={'color':'rgb(205,92,92)'},
              name='North America',
              showlegend=False,
              xaxis='x2',
              yaxis='y2')

trace8 = dict(type='scatter',
              x=gas_cons.index,
              y=gas_cons['South America'],
              mode='lines',
              marker={'color':'rgb(255,127,80)'},
              name='South America',
              showlegend=False,
              xaxis='x2',
              yaxis='y2')

trace9 = dict(type='scatter',
              x=gas_cons.index,
              y=gas_cons['Africa'],
              mode='lines',
              marker={'color':'rgb(255,215,0)'},
              name='Africa',
              showlegend=False,
              xaxis='x2',
              yaxis='y2')

trace10 = dict(type='scatter',
              x=gas_cons.index,
              y=gas_cons['Middle East'],
              mode='lines',
              marker={'color':'rgb(147,112,219)'},
              name='Middle East',
              showlegend=False,
              xaxis='x2',
              yaxis='y2')

trace11 = dict(type='scatter',
              x=gas_cons.index,
              y=gas_cons['Asia Pacific'],
              mode='lines',
              marker={'color':'rgb(143,188,143)'},
              name='Asia Pacific',
              showlegend=False, 
              xaxis='x2',
              yaxis='y2')

trace12 = dict(type='scatter',
              x=gas_cons.index,
              y=gas_cons['Europe/Eurasia'],
              mode='lines',
              marker={'color':'rgb(100,149,237)'},
              name='Europe/Eurasia',
              showlegend=False,
              xaxis='x2',
              yaxis='y2')

trace13 = dict(type='scatter',
              x=coal_cons.index,
              y=coal_cons['North America'],
              mode='lines',
              marker={'color':'rgb(205,92,92)'},
              name='North America',
              showlegend=False,
              xaxis='x3',
              yaxis='y3')

trace14 = dict(type='scatter',
              x=coal_cons.index,
              y=coal_cons['South America'],
              mode='lines',
              marker={'color':'rgb(255,127,80)'},
              name='South America',
              showlegend=False,
              xaxis='x3',
              yaxis='y3')

trace15 = dict(type='scatter',
              x=coal_cons.index,
              y=coal_cons['Africa'],
              mode='lines',
              marker={'color':'rgb(255,215,0)'},
              name='Africa',
              showlegend=False,
              xaxis='x3',
              yaxis='y3')

trace16 = dict(type='scatter',
              x=coal_cons.index,
              y=coal_cons['Middle East'],
              mode='lines',
              marker={'color':'rgb(147,112,219)'},
              name='Middle East',
              showlegend=False,
              xaxis='x3',
              yaxis='y3')

trace17 = dict(type='scatter',
              x=coal_cons.index,
              y=coal_cons['Asia Pacific'],
              mode='lines',
              marker={'color':'rgb(143,188,143)'},
              name='Asia Pacific',
              showlegend=False, 
              xaxis='x3',
              yaxis='y3')

trace18 = dict(type='scatter',
              x=coal_cons.index,
              y=coal_cons['Europe/Eurasia'],
              mode='lines',
              marker={'color':'rgb(100,149,237)'},
              name='Europe/Eurasia',
              showlegend=False,
              xaxis='x3',
              yaxis='y3')

data = [trace1, trace2, trace3, trace4, trace5, trace6, 
        trace7, trace8, trace9, trace10, trace11, trace12,
        trace13, trace14, trace15, trace16, trace17, trace18]

layout = go.Layout(
    title='Fossil Fuel Consumption by Region</br>(in million tonnes oil equivalent)',
    width=1050,
    height=400,
    legend=dict(x=.85, y=1),
    xaxis=dict(
        title='Oil',
        domain=[0, 0.25]),
    yaxis=dict(
        range=[0, 2900]),
    xaxis2=dict(
        title='Natural Gas',
        domain=[0.3, 0.55]),
    yaxis2=dict(
        anchor='x2',
        range=[0, 2900]), 
    xaxis3=dict(
        title='Coal',
        domain=[0.6, 0.85]),
    yaxis3=dict(
        anchor='x3',
        range=[0, 2900]))

iplot(go.Figure(data=data, layout=layout))


Asia Pacific has led in oil consumption for almost the past decade and in coal consumption for almost three decades now - consistent with the carbon dioxide data above which indicates that this region also produces the most emissions. Impressively Europe/Eurasia has decreased its oil and coal consumption for a couple decades now, while North America indifferently just barely fluctuates. It is interesting considering these trends that North America and Europe emit about the same level of carbon dioxide emissions when it is well-known in the political community that the European Union puts great effort into these results while the United States does not.

Reserves


In [117]:
# oil reserves by region since 1980
# clean up and shape
# units = thousand million barrels a.k.a. billion barrels
# convert: 1 barrel = .1364 metric tonnes

oil_res = pd.read_excel(url, 
                        sheetname='Oil - Proved reserves history',
                        index_col=0,
                        skiprows=2)

oil_res = oil_res.drop(['2014.1','of total'], axis=1)

oil_res = oil_res.ix[['Total North America', 'Total S. & Cent. America', 'Total Africa', 
                      'Total Middle East', 'Total Asia Pacific', 'Total Europe & Eurasia']]

oil_res.index = ['North America', 'South America', 'Africa',
                 'Middle East', 'Asia Pacific', 'Europe/Eurasia']

oil_res = oil_res*(.1364)*1000   # convert to million metric tonnes

oil_res = oil_res.astype(int).round()   # convert to integer and round up 

oil_res = oil_res.T

oil_res.head()


Out[117]:
North America South America Africa Middle East Asia Pacific Europe/Eurasia
1980 16816 3647 7288 49432 4627 11400
1981 18232 3707 7676 49822 4815 10744
1982 18057 4409 7948 53046 4822 10684
1983 18171 4558 7916 54139 4952 10831
1984 18145 4952 7879 58755 5159 10743

In [118]:
# natural gas reserves by region since 1980
# clean up and shape
# units = trillion cubic metres
# convert: 1 billion cubic metres = .90 million tonnes oil equivalent

gas_res = pd.read_excel(url, 
                        sheetname='Gas - Proved reserves history ',
                        index_col=0,
                        skiprows=2)

gas_res = gas_res.drop(['2014.1','of total'], axis=1)

gas_res = gas_res.ix[['Total North America', 'Total S. & Cent. America', 'Total Africa', 
                      'Total Middle East', 'Total Asia Pacific', 'Total Europe & Eurasia']]

gas_res.index = ['North America', 'South America', 'Africa',
                 'Middle East', 'Asia Pacific', 'Europe/Eurasia']

gas_res = gas_res*.9*1000   # convert to million tonnes oil equivalent

gas_res = gas_res.astype(int).round()

gas_res = gas_res.T

gas_res.head()


Out[118]:
North America South America Africa Middle East Asia Pacific Europe/Eurasia
1980 8959 2424 5390 22223 4035 21379
1981 9368 2591 5321 22503 5030 22333
1982 9388 2714 5657 23295 5431 22766
1983 9417 2768 5658 23744 5614 23529
1984 9515 2830 5593 24661 6258 24295

In [119]:
# find maximum y value for plot

oil_res.max()


Out[119]:
North America      32459
South America      45248
Africa             17812
Middle East       109633
Asia Pacific        5851
Europe/Eurasia     21873
dtype: int64

In [120]:
# find maximum y value for plot

gas_res.max()


Out[120]:
North America     11476
South America      6907
Africa            13284
Middle East       72055
Asia Pacific      14168
Europe/Eurasia    51390
dtype: int64

In [121]:
# plot oil and natural gas reserves by region since 1980
# max = 109593 - oil, Middle East

trace1 = dict(type='scatter',
              x=oil_res.index,
              y=oil_res['North America'],
              mode='lines+markers',
              marker={'color':'rgb(205,92,92)'},
              name='North America')

trace2 = dict(type='scatter',
              x=oil_res.index,
              y=oil_res['South America'],
              mode='lines+markers',
              marker={'color':'rgb(255,127,80)'},
              name='South America')

trace3 = dict(type='scatter',
              x=oil_res.index,
              y=oil_res['Africa'],
              mode='lines+markers',
              marker={'color':'rgb(255,215,0)'},
              name='Africa')

trace4 = dict(type='scatter',
              x=oil_res.index,
              y=oil_res['Middle East'],
              mode='lines+markers',
              marker={'color':'rgb(147,112,219)'},
              name='Middle East')

trace5 = dict(type='scatter',
              x=oil_res.index,
              y=oil_res['Asia Pacific'],
              mode='lines+markers',
              marker={'color':'rgb(143,188,143)'},
              name='Asia Pacific')

trace6 = dict(type='scatter',
              x=oil_res.index,
              y=oil_res['Europe/Eurasia'],
              mode='lines+markers',
              marker={'color':'rgb(100,149,237)'},
              name='Europe/Eurasia')

trace7 = dict(type='scatter',
              x=gas_res.index,
              y=gas_res['North America'],
              mode='lines+markers',
              marker={'color':'rgb(205,92,92)'},
              name='North America',
              showlegend=False,
              xaxis='x2',
              yaxis='y2')

trace8 = dict(type='scatter',
              x=gas_res.index,
              y=gas_res['South America'],
              mode='lines+markers',
              marker={'color':'rgb(255,127,80)'},
              name='South America',
              showlegend=False,
              xaxis='x2',
              yaxis='y2')

trace9 = dict(type='scatter',
              x=gas_res.index,
              y=gas_res['Africa'],
              mode='lines+markers',
              marker={'color':'rgb(255,215,0)'},
              name='Africa',
              showlegend=False,
              xaxis='x2',
              yaxis='y2')

trace10 = dict(type='scatter',
              x=gas_res.index,
              y=gas_res['Middle East'],
              mode='lines+markers',
              marker={'color':'rgb(147,112,219)'},
              name='Middle East',
              showlegend=False,
              xaxis='x2',
              yaxis='y2')

trace11 = dict(type='scatter',
              x=gas_res.index,
              y=gas_res['Asia Pacific'],
              mode='lines+markers',
              marker={'color':'rgb(143,188,143)'},
              name='Asia Pacific',
              showlegend=False, 
              xaxis='x2',
              yaxis='y2')

trace12 = dict(type='scatter',
              x=gas_res.index,
              y=gas_res['Europe/Eurasia'],
              mode='lines+markers',
              marker={'color':'rgb(100,149,237)'},
              name='Europe/Eurasia',
              showlegend=False,
              xaxis='x2',
              yaxis='y2')

data = [trace1, trace2, trace3, trace4, trace5, trace6, 
        trace7, trace8, trace9, trace10, trace11, trace12]

layout = go.Layout(
    title='Fossil Fuel Reserves by Region',
    width=1000,
    height=500,
    xaxis=dict(
        domain=[0, 0.4],
        title='Oil'),
    yaxis=dict(
        title='Reserves (in million metric tonnes)',
        range=[0, 111000]),
    xaxis2=dict(
        domain=[0.6, 1],
        title='Natural Gas'),
    yaxis2=dict(
        title='Reserves (in million tonnes oil equivalent)',
        anchor='x2',
        range=[0, 111000]))

iplot(go.Figure(data=data, layout=layout))


Reserves estimate the available fuel based on current technology levels to access them. As such, I wanted to observe reserves over time to demonstrate the rush for oil and natural gas. (Unfortunately data on coal was unavailable.) As we see above, approximated reserves in the Middle East far outnumber those in other regions of the world. This is of particular interest considering that the Middle East exhibits a consistently low level of consumption of both oil and natural gas compared to the rest of the world. Europe's transition to increased sustainability may make more sense given their high reserves of natural gas, which burns more cleanly than oil or coal. Perhaps their transition was facilitated by these stores which North America does not parallel.

Renewable Energy Capacity

What We're Currently Using


In [122]:
# clean up and shape 2015 data
# units = million tonnes oil equivalent

consumption = pd.read_excel(url, 
                            sheetname='Primary Energy - Cons by fuel',
                            index_col=0,
                            skiprows=2)

consumption = consumption.drop(consumption.columns[0:7], axis=1)

consumption.columns = ['Oil', 'Natural Gas', 'Coal', 'Nuclear', 'Hydro', 'Renewables', 'Total']

consumption = consumption.ix[['Total North America', 'Total S. & Cent. America', 'Total Africa', 
                              'Total Middle East', 'Total Asia Pacific', 'Total Europe & Eurasia']]

consumption.index = ['North America', 'South America', 'Africa',
                     'Middle East', 'Asia Pacific', 'Europe/Eurasia']

consumption = consumption.astype(int).round()

consumption


Out[122]:
Oil Natural Gas Coal Nuclear Hydro Renewables Total
North America 1036 880 428 216 150 82 2795
South America 322 157 37 4 152 24 699
Africa 182 121 96 2 27 3 434
Middle East 425 441 10 0 5 0 884
Asia Pacific 1501 631 2798 94 361 110 5498
Europe/Eurasia 862 903 467 263 194 142 2834

In [149]:
# plot energy consumption in the six regions in 2015

trace1 = go.Bar(
    y=['North<br>America', 'South<br>America', 'Africa',
       'Middle<br>East', 'Asia<br>Pacific', 'Europe/<br>Eurasia'],
    x=consumption['Oil'],
    name='Oil',
    orientation='h',
    marker={'color':'rgb(205,92,92)'})

trace2 = go.Bar(
    y=['North<br>America', 'South<br>America', 'Africa',
       'Middle<br>East', 'Asia<br>Pacific', 'Europe/<br>Eurasia'],
    x=consumption['Natural Gas'],
    name='Natural Gas',
    orientation='h', 
    marker={'color':'rgb(255,127,80)'})

trace3 = go.Bar(
    y=['North<br>America', 'South<br>America', 'Africa',
       'Middle<br>East', 'Asia<br>Pacific', 'Europe/<br>Eurasia'],
    x=consumption['Coal'],
    name='Coal',
    orientation='h', 
    marker={'color':'rgb(255,215,0)'})

trace4 = go.Bar(
    y=['North<br>America', 'South<br>America', 'Africa',
       'Middle<br>East', 'Asia<br>Pacific', 'Europe/<br>Eurasia'],
    x=consumption['Nuclear'],
    name='Nuclear',
    orientation='h', 
    marker={'color':'rgb(147,112,219)'})

trace5 = go.Bar(
    y=['North<br>America', 'South<br>America', 'Africa',
       'Middle<br>East', 'Asia<br>Pacific', 'Europe/<br>Eurasia'],
    x=consumption['Hydro'],
    name='Hydro',
    orientation='h', 
    marker={'color':'rgb(143,188,143)'})

trace6 = go.Bar(
    y=['North<br>America', 'South<br>America', 'Africa',
       'Middle<br>East', 'Asia<br>Pacific', 'Europe/<br>Eurasia'],
    x=consumption['Renewables'],
    name='Renewables',
    orientation='h', 
    marker={'color':'rgb(100,149,237)'})

data = [trace1, trace2, trace3, trace4, trace5, trace6]
layout = dict(width=900, 
              height=500,
              title='World Energy Consumption by Region in 2015', 
              xaxis={'title': 'Consumption (in million tonnes oil equivalent)'}, 
              barmode='stack')

iplot(go.Figure(data=data, layout=layout))


Having looked specfically at fossil fuel consumption, we now examine regional energy usage by renewables, hydroelectricity, nuclear, coal, natural gas, and oil. As we can see in the graph above, Asia Pacific leads in energy usage in the world - likely due to China. While Europe comes in second, trailed closely by North America, the two combined about equal Asia Pacific's consumption in million tonnes oil equivalent. Oil, natural gas, and coal consistently make up the top three energy sources in descending order throughout the world, excpept for in Asia Pacific where coal surpasses oil. Renewable energy trails last in all regions, with zero data at all for the Middle East. It is not promising that all types of renewable energy are grouped into one category and still sum up to such a minimal value.

What We Could Be Using


In [244]:
# solar energy capacity in 2015 to compare to consumption
# clean up and shape
# units = megawatt-hours
# convert: 12 megawatt-hours = one tonne oil equivalent

solar = pd.read_excel(url, 
                      sheetname='Solar capacity',
                      index_col=0,
                      skiprows=3)

solar = solar.drop(solar.columns[0:19], axis=1).drop(solar.columns[20:23], axis=1)   # only 2015 capacity

solar = solar.ix[['Total North America']]

solar.index = ['North America']

solar = solar.astype(int)

solar = solar/12*.000001   # convert to million tonnes oil equivalent

solar = solar.T

solar


Out[244]:
North America
2015 0.002364

In [211]:
# solar energy capacity in 2015 to compare to consumption
# clean up and shape
# units = megawatt-hours
# convert: 12 megawatt-hours = one tonne oil equivalent

wind = pd.read_excel(url, 
                      sheetname='Wind capacity',
                      index_col=0,
                      skiprows=3)

wind = wind.drop(wind.columns[0:20], axis=1).drop(wind.columns[21:24], axis=1)   # only 2015 capacity

wind = wind.ix[['Total North America', 'Total S. & Cent. America', 'Total Africa', 
                'Total Middle East', 'Total Asia Pacific', 'Total Europe & Eurasia']]

wind.index = ['North America', 'South America', 'Africa',
              'Middle East', 'Asia Pacific', 'Europe/Eurasia']

wind = wind.astype(int)

wind = wind/12*.000001   # convert to million tonnes oil equivalent

wind = wind.T

wind


Out[211]:
North America South America Africa Middle East Asia Pacific Europe/Eurasia
2015 0.007429 0.001087 0.000293 0.000023 0.015054 0.01234

In [354]:
# plot fossil fuel consumption against wind capacity

trace1 = go.Bar(
    y=consumption['Natural Gas'],
    x=['North<br>America', 'South<br>America', 'Africa',
       'Middle<br>East', 'Asia<br>Pacific', 'Europe/<br>Eurasia'],
    name='Natural Gas Consumption',
    marker={'color':'rgb(255,127,80)'})

trace2 = go.Bar(
    y=[0.007429, 0.001087, 0.000293, 0.000023, 0.015054, 0.01234],
    x=['North<br>America', 'South<br>America', 'Africa',
       'Middle<br>East', 'Asia<br>Pacific', 'Europe/<br>Eurasia'],
    name='Wind Capacity', 
    marker={'color':'rgb(100,149,237)'})

trace3 = go.Bar(
    y=consumption['Natural Gas'],
    x=['Natural Gas</br>Consumption'],
    name='Natural Gas Consumption',
    marker={'color':'rgb(255,127,80)'},
    showlegend=False,
    xaxis='x2',
    yaxis='y2')

trace4 = go.Bar(
    y=wind['North America'],
    x=['Wind</br>Capacity'],
    name='Wind Capacity',
    marker={'color':'rgb(100,149,237)'},
    showlegend=False,
    xaxis='x2',
    yaxis='y2')

trace5 = go.Bar(
    y=solar['North America'],
    x=['Solar</br>Capacity'],
    name='Solar Capacity',
    marker={'color':'rgb(255,215,0)'},
    xaxis='x2',
    yaxis='y2')

data = [trace1, trace2, trace3, trace4, trace5]
layout = dict(width=1000, 
              height=400,   
              legend=dict(x=.85, y=1),
              title='World Energy Consumption vs. Renewable Capacity',
              xaxis=dict(domain=[0, 0.4],
                         title='Worldwide'),
              yaxis=dict(title='Million tonnes oil equivalent', 
                         range=[0, .15]),
              xaxis2=dict(domain=[0.5, .9], 
                          title='North America'),
              yaxis2=dict(anchor='x2',
                          range=[0, .15]),
              barmode='group',
              bargap=2,
              bargroupgap=0.4,
              annotations=[
        dict(x='North America',
             y=.075,
             xref='x',
             yref='y',
             text='The red bars have values between 121 and 903</br>and have been SCALED DOWN up to <b>6,000</b> times</br>to demonstrate wind capacity worldwide in blue.',
             showarrow=False),
        dict(x=.3,
             y=.15,
             xref='x2',
             yref='y2',
             text='Ditto!!!!!!',
             showarrow=True,
             arrowhead=2,
             ax=30,
             ay=-30)])

iplot(go.Figure(data=data, layout=layout))


While we must keep in mind that the above reflects only available data, it is disappointing to find that so little capacity is estimated for wind or solar-sourced energy. This graph compares only natural gas consumption to wind capacity because natural gas is the least emitted fossil fuel. Data on solar capacity was unavailable except for North America so the figure on the right compares consumption and renewable energy sources. Knowing this, it is all the more striking to see (or to barely see) the current capacity for renewable energy in the world compared to what we are actually consuming. While this is an otherwise useless graph, it is quite dramatic in demonstrating our reliance on harmful energy sources.

Conclusion

This data project aimed to impart a brief snapshot of the energy system in the world today: including how much CO2 we're putting into the environment by using energy and what kinds of energy we're using and rely on most. Sadly, the numbers for renewable energy are dismal compared to our current consumption rates - indicating a dire need to diversify our energy sources to secure a sustainable future.

References

BP. "BP Statistical Review Of World Energy 2016". London: BP Statistical Review of World Energy, 2016. Web. 5 May 2017.