http://www.wri.org/resources/data-sets/unfccc-annex-i-ghg-emissions-0
In [1]:
import csv
In [3]:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.mlab as mlab
# import prettyplotlib as ppl
import pandas as pd
In [12]:
cy = pd.read_csv('WRIdata/CAIT 2.0 Country GHG Emissions.csv')
cy = cy.replace('', '0')
cy = cy.fillna(0)
In [16]:
cy.to_pickle("WRIdata/CountyGHGs.pkl")
cy.columns
Out[16]:
In [17]:
e2011 = cy[cy['Year'] == 2011]
In [18]:
len(e2011['Country'])
e2011.head()
Out[18]:
In [16]:
e2011 = e2011.sort('Total GHG Emissions Including Land-Use Change and Forestry (MtCO2e)', ascending = 0)
e2011mini = e2011[['Total GHG Emissions Including Land-Use Change and Forestry (MtCO2e)','Country']]
# get rid of World total
# also get rid of EU15 and EU28
pieces = [e2011mini[1:3],e2011mini[5:]]
e2011totals = pd.concat(pieces)
In [17]:
ts = e2011totals['Total GHG Emissions Including Land-Use Change and Forestry (MtCO2e)']
# top 10 countries get called out.
# group everyone else in Other
other = ts.values[10:].sum()
topten = ts.values[0:9]
plt.pie(np.insert(topten, 0, other), labels = np.insert(e2011totals[0:9]['Country'].values, 0, 'Other'))
plt.show()
In [18]:
e2011 = e2011.sort('Total GHG Emissions Excluding Land-Use Change and Forestry (MtCO2e)', ascending = 0)
e2011mini = e2011[['Total GHG Emissions Excluding Land-Use Change and Forestry (MtCO2e)','Country']]
# get rid of World total
# also get rid of EU15 and EU28
pieces = [e2011mini[1:3],e2011mini[5:]]
e2011totals = pd.concat(pieces)
In [19]:
ts = e2011totals['Total GHG Emissions Excluding Land-Use Change and Forestry (MtCO2e)']
# top 10 countries get called out.
# group everyone else in Other
other = ts.values[10:].sum()
topten = ts.values[0:9]
plt.pie(np.insert(topten, 0, other), labels = np.insert(e2011totals[0:9]['Country'].values, 0, 'Other'))
plt.show()
In [20]:
other
Out[20]:
In [21]:
e2011mini[0:10]
Out[21]:
In [22]:
ts.values.sum()
Out[22]:
In [23]:
topten
Out[23]:
In [24]:
# USAtotal emissions excluding LUC = 6550.0981
energy_sectors = ['Electricity/Heat (MtCO2)','Manufacturing/Construction (MtCO2)', 'Transportation (MtCO2)',
'Fugitive Emissions (MtCO2e)', 'Other Fuel Combustion (MtCO2e)']
sectors = ['Energy (MtCO2e)', 'Industrial Processes (MtCO2e)',
'Agriculture (MtCO2e)',
'Waste (MtCO2e)', 'Bunker Fuels (MtCO2)']
USA2011 = e2011[2:3]
USA2011
Out[24]:
In [25]:
e2011[2:3][energy_sectors]
Out[25]:
In [26]:
print USA2011[energy_sectors].values.sum()
print USA2011['Energy (MtCO2e)'].values
print USA2011[sectors].values.sum()
print 6550.0981
In [66]:
# e2011[1:3][e2011[sectors][1:2].keys()[0]]
top_four_pieces = [e2011[1:3],e2011[5:7]]
top_four = pd.concat(top_four_pieces)
top_four[sectors].sum()
Out[66]:
In [31]:
e2011[sectors][0:1]-top_four[sectors].sum()
Out[31]:
In [29]:
top_ten_pieces = [e2011[1:3],e2011[5:13]]
top_ten = pd.concat(top_ten_pieces)
e2011[sectors][0:1]-top_ten[sectors].sum()
e2011[energy_sectors][0:1]-top_ten[energy_sectors].sum()
Out[29]:
In [49]:
EU28_names = ['Austria', 'Belgium', 'Bulgaria', 'Croatia', 'Cyprus', 'Czech Republic', 'Denmark', 'Estonia',
'Finland', 'France', 'Germany', 'Greece', 'Hungary', 'Italy', 'Latvia', 'Lithuania', 'Luxembourg',
'Malta', 'Netherlands', 'Poland', 'Portugal', 'Romania', 'Slovakia', 'Slovenia', 'Spain', 'Sweden',
'United Kingdom']
In [57]:
EU28_subset = e2011[e2011['Country'].isin(EU28_names)]
In [78]:
e2011_wo_EU28 = e2011[~e2011['Country'].isin(EU28_names + ['World', 'European Union (15)'])]
first20_EU28 = e2011_wo_EU28[0:20][sectors + energy_sectors + ['Country']]
In [73]:
# collapse all other countries into one entry
e2011_wo_EU28[20:][sectors].sum()
Out[73]:
In [74]:
e2011_wo_EU28[20:][energy_sectors].sum()
Out[74]:
In [ ]: