pandas


In [2]:
import csv
import pandas as pd

In [9]:
dict_reader = csv.DictReader(open('data/CAIT 2.0 Country GHG Emissions.csv'))
country_year = []
for row in dict_reader:
    keys = row.keys()
    clean_row = {}
    for key in keys:
        clean_row[key] = row[key].strip()
    country_year.append(clean_row)

In [10]:
cy = pd.read_csv('data/CAIT 2.0 Country GHG Emissions.csv')

In [44]:
country_year
cy[cy["Country"].isin(["Germany", "Austria"])]


Out[44]:
Country Year Total GHG Emissions Excluding Land-Use Change and Forestry (MtCO2e) Total GHG Emissions Including Land-Use Change and Forestry (MtCO2e) Total CO? Excluding Land-Use Change and Forestry (MtCO2) Total CH4 (MtCO2e) Total N2O (MtCO2e) Total F-Gas (MtCO2e) Energy (MtCO2e) Industrial Processes (MtCO2e) Agriculture (MtCO2e) Waste (MtCO2e) LUCF (MtCO2) Bunker Fuels (MtCO2) Electricity/Heat (MtCO2) Manufacturing/Construction (MtCO2) Transportation (MtCO2) Other Fuel Combustion (MtCO2e) Fugitive Emissions (MtCO2e)
176 Austria 1990 74.9340 62.1559 58.8802 8.357588 6.260281 1.435894 57.655646 5.035472 8.676659 3.556211 -12.77809 0.86 19.78 10.08 13.64 13.946938 0.208707
177 Austria 1991 79.0045 66.2084 63.0588 8.215910 6.334795 1.394931 61.793464 5.042084 8.699697 3.459241 -12.79612 0.96 20.66 10.59 15.03 15.301357 0.212107
178 Austria 1992 74.0037 61.1715 58.1662 8.074233 6.409309 1.353969 56.921282 4.997399 8.722735 3.362271 -12.83217 1.04 17.38 9.67 15.04 14.615776 0.215506
179 Austria 1993 74.1716 61.3034 58.4422 7.932555 6.483823 1.313006 57.259100 4.901418 8.745773 3.265301 -12.86823 1.10 17.47 10.08 15.18 14.310195 0.218905
180 Austria 1994 74.1885 61.2842 58.5672 7.790877 6.558337 1.272043 57.466918 4.794445 8.768811 3.168330 -12.90428 1.14 18.85 9.84 15.24 13.314614 0.222304
181 Austria 1995 76.8094 63.8691 61.2963 7.649199 6.632851 1.231080 60.684736 4.251457 8.791849 3.071360 -12.94033 1.28 20.43 10.12 15.45 14.459033 0.225703
182 Austria 1996 80.2882 67.3119 65.0609 7.449835 6.564551 1.212927 64.444008 4.266895 8.628689 2.958649 -12.97639 1.42 20.94 10.36 17.07 15.850811 0.223197
183 Austria 1997 79.2814 66.2690 64.3399 7.250471 6.496251 1.194773 63.703280 4.256685 8.465528 2.845937 -13.01246 1.47 21.32 11.68 16.15 14.332590 0.220690
184 Austria 1998 79.4956 66.4471 64.8399 7.051106 6.427951 1.176619 64.202552 4.257468 8.302367 2.733225 -13.04851 1.54 20.46 10.90 18.25 14.374368 0.218184
185 Austria 1999 77.6415 64.5569 63.2716 6.851742 6.359651 1.158465 62.641824 4.239930 8.139207 2.620513 -13.08456 1.49 19.58 10.21 17.76 14.876146 0.215678
186 Austria 2000 77.6673 64.5467 63.5833 6.652378 6.291351 1.140311 62.961096 4.222393 7.976046 2.507801 -13.12062 1.63 19.21 11.30 18.50 13.737924 0.213171
187 Austria 2001 81.5971 64.3176 67.7643 6.543902 6.111568 1.177361 67.137434 4.123388 7.863260 2.463037 -17.27952 1.59 20.98 11.05 19.97 14.919769 0.217664
188 Austria 2002 82.9345 65.6155 69.3529 6.435426 5.931786 1.214410 68.693771 4.072016 7.750474 2.418272 -17.31901 1.49 21.44 10.96 21.84 14.231614 0.222157
189 Austria 2003 87.8550 70.4970 74.5246 6.326950 5.752004 1.251459 73.900109 3.943700 7.637688 2.373508 -17.35805 1.41 23.58 11.70 23.40 14.993459 0.226651
190 Austria 2004 88.9483 71.5509 75.8691 6.218474 5.572221 1.288508 75.036447 4.068200 7.524901 2.328744 -17.39736 1.67 24.16 12.38 23.73 14.535303 0.231144
191 Austria 2005 89.7697 72.3322 76.9417 6.109998 5.392439 1.325558 76.012785 4.060796 7.412115 2.283979 -17.43743 1.89 24.72 12.62 24.45 13.987148 0.235637
192 Austria 2006 87.7557 92.3648 74.9182 6.010376 5.455878 1.371213 73.828167 4.278990 7.449715 2.198834 4.60913 1.98 24.35 12.61 23.18 13.454362 0.233806
193 Austria 2007 85.4511 90.0768 72.6041 5.910754 5.519316 1.416869 71.323550 4.526497 7.487315 2.113689 4.62574 2.10 23.93 12.11 23.37 11.681576 0.231975
194 Austria 2008 86.1118 90.7534 73.2554 5.811132 5.582755 1.462525 71.908933 4.649428 7.524916 2.028544 4.64154 2.11 23.96 13.41 22.04 12.268789 0.230143
195 Austria 2009 79.3915 84.0492 66.5256 5.711510 5.646194 1.508180 65.504315 4.391303 7.562516 1.943399 4.65771 1.83 20.46 12.28 21.47 11.066003 0.228312
196 Austria 2010 85.0568 89.7307 72.1815 5.611888 5.709633 1.553836 71.339698 4.268746 7.600116 1.858254 4.67391 1.98 24.43 12.25 22.16 12.273217 0.226481
197 Austria 2011 83.6993 88.3732 70.6977 5.619402 5.760892 1.621245 69.767853 4.421615 7.651142 1.858660 4.67391 2.06 24.69 12.16 21.62 11.072787 0.225066
1430 Germany 1990 1170.6905 1107.4739 968.4600 105.603288 90.130354 6.496875 961.860808 52.680302 87.002776 43.111498 -63.21663 21.13 402.63 179.26 157.59 222.380808 NaN
1431 Germany 1991 1141.5211 1078.1033 942.9715 102.488747 89.260737 6.800162 962.310678 51.837333 84.919839 42.453248 -63.41781 19.25 399.98 153.93 160.28 222.184333 25.936346
1432 Germany 1992 1100.8033 1036.9831 905.9345 99.374206 88.391119 7.103450 921.956391 54.215020 82.836902 41.794998 -63.82017 19.08 383.75 145.92 162.79 204.977857 24.518533
1433 Germany 1993 1089.9713 1025.7488 898.7834 96.259665 87.521502 7.406737 913.488454 54.592163 80.753965 41.136747 -64.22252 21.25 375.97 137.48 167.36 209.321382 23.357071
1434 Germany 1994 1075.3534 1010.7285 887.8463 93.145123 86.651884 7.710024 901.051336 55.152506 78.671029 40.478497 -64.62488 22.09 376.24 139.31 164.81 197.754907 22.936429
1435 Germany 1995 1069.1875 1004.1603 885.3614 90.030582 85.782267 8.013311 898.230509 54.558689 76.588092 39.820247 -65.02723 22.19 370.37 140.07 166.68 199.668432 21.442077
1436 Germany 1996 1090.0924 1024.6622 913.1011 86.450525 82.057757 8.482937 926.072973 50.008721 76.738323 37.272343 -65.43018 22.49 381.12 132.30 167.78 224.124015 20.748958
1437 Germany 1997 1054.5583 988.7256 884.4020 82.870467 78.333246 8.952563 894.411467 48.543841 76.888555 34.724440 -65.83274 23.58 365.48 131.08 168.43 209.449598 19.971869
1438 Germany 1998 1041.1293 974.8944 877.8080 79.290410 74.608736 9.422189 886.717341 45.206658 77.038786 32.176536 -66.23491 23.87 365.47 129.90 171.33 200.715181 19.302160
1439 Germany 1999 1003.8816 937.2443 847.3952 75.710352 70.884225 9.891816 855.872295 41.191634 77.189018 29.628632 -66.63727 25.08 351.40 124.34 176.11 183.310764 20.711531
1440 Germany 2000 994.8552 927.8154 845.2038 72.130295 67.159715 10.361442 853.159689 37.275539 77.339249 27.080729 -67.03983 26.35 356.29 126.26 171.89 178.746347 19.973342
1441 Germany 2001 1008.8681 955.3679 861.7905 69.152698 66.779153 11.145801 870.599851 36.515479 76.577768 25.185046 -53.50029 25.62 368.40 120.29 167.96 194.815112 19.134739
1442 Germany 2002 993.1553 939.6549 848.6514 66.175102 66.398590 11.930160 857.206014 36.843627 75.816286 23.289363 -53.50036 26.11 370.17 120.31 165.55 182.893877 18.282137
1443 Germany 2003 984.4538 930.9535 842.5238 63.197506 66.018028 12.714519 849.401916 38.593408 75.054805 21.393680 -53.50034 27.32 374.06 117.61 160.62 179.772642 17.339274
1444 Germany 2004 985.5316 932.0327 846.1753 60.219909 65.637465 13.498879 852.722459 39.027812 74.293324 19.497997 -53.49885 29.26 382.16 120.82 162.64 170.771408 16.331051
1445 Germany 2005 954.5998 901.0995 817.8173 57.242313 65.256903 14.283238 823.977751 39.487864 73.531842 17.602314 -53.50032 30.39 367.47 120.26 154.89 165.820173 15.537578
1446 Germany 2006 965.5155 888.5549 832.3991 54.315077 64.181395 14.619890 837.012320 41.344575 71.007761 16.150842 -76.96061 31.80 373.75 122.05 152.48 173.699382 15.032938
1447 Germany 2007 935.4004 858.4334 805.9501 51.387841 63.105887 14.956542 810.448659 41.768661 68.483679 14.699371 -76.96702 34.23 386.52 123.57 148.23 137.688592 14.440068
1448 Germany 2008 938.7277 861.8190 812.9435 48.460606 62.030379 15.293193 817.113968 42.416251 65.959598 13.247899 -76.90871 34.27 366.85 123.36 147.02 166.027801 13.856167
1449 Germany 2009 876.1988 799.2322 754.0807 45.533370 60.954871 15.629845 759.576488 41.400385 63.435516 11.796427 -76.96658 32.86 338.75 106.06 147.16 154.307011 13.299477
1450 Germany 2010 903.9783 827.0112 785.5263 42.606134 59.879363 15.966497 791.053957 41.677912 60.911435 10.344956 -76.96702 32.70 353.46 115.57 147.01 162.466221 12.547736
1451 Germany 2011 882.9341 805.9671 765.9803 42.020623 58.041694 16.891529 769.594747 42.752812 60.640635 9.945956 -76.96702 31.71 350.51 114.15 148.74 143.711204 12.483543

In [18]:
scope1 = pd.read_pickle('data/scope1totals.pkl')

In [52]:
scope1.loc["Australia", "Energy"]


Out[52]:
Scope 1    30550166
Name: (Australia, Energy), dtype: float64

In [53]:
import newf

In [54]:
newf.favcolumn(scope1, 4)


hello

In [55]:
reload(newf)


Out[55]:
<module 'newf' from 'newf.pyc'>

In [ ]: