In [74]:
%matplotlib inline
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np

In [2]:
fn1 = 'EPA emissions.txt'
fn2 = 'may_generator2016.xlsx'
fn3 = 'EIA923_Schedules_2_3_4_5_M_10_2016.xlsx'

Load emissions data


In [3]:
emissions = pd.read_csv(fn1)

In [4]:
emissions.head()


Out[4]:
State Facility Name Facility ID (ORISPL) Unit ID Associated Stacks Month Year Program(s) Operating Time Gross Load (MW-h) Steam Load (1000lb) SO2 (tons) Avg. NOx Rate (lb/MMBtu) NOx (tons) CO2 (short tons) Heat Input (MMBtu) EPA Region NERC Region Unit Type Fuel Type (Primary)
AL AMEA Sylacauga Plant 56018 1 NaN 5 2016 CSNOX, CSNOXOS, CSSO2G2, ARP 28.00 1149.0 NaN 0.004 0.0759 0.473 732.800 12428.200 4 SERC Combustion turbine Pipeline Natural Gas NaN
AL AMEA Sylacauga Plant 56018 2 NaN 5 2016 CSNOX, CSNOXOS, CSSO2G2, ARP 17.00 642.0 NaN 0.002 0.0809 0.283 412.300 6984.600 4 SERC Combustion turbine Pipeline Natural Gas NaN
AL Barry 3 1 CS0AAN 5 2016 ARP, CSNOX, CSNOXOS, CSSO2G2 2.75 11.0 NaN 0.005 0.0080 0.001 14.213 240.050 4 SERC Tangentially-fired Pipeline Natural Gas NaN
AL Barry 3 2 CS0AAN 5 2016 ARP, CSNOX, CSNOXOS, CSSO2G2 2.75 11.0 NaN 0.005 0.0080 0.001 14.213 240.050 4 SERC Tangentially-fired Pipeline Natural Gas NaN
AL Barry 3 4 NaN 5 2016 ARP, MATS, CSNOX, CSNOXOS, CSSO2G2 725.25 116336.0 NaN 572.537 0.4319 265.224 128402.000 1251483.675 4 SERC Tangentially-fired Coal NaN

From the read_csv docstring:

index_col : int or sequence or False, default None
Column to use as the row labels of the DataFrame. If a sequence is given, a
MultiIndex is used. If you have a malformed file with delimiters at the end
of each line, you might consider index_col=False to force pandas to _not_
use the first column as the index (row names)

In [7]:
emissions = pd.read_csv(fn1, index_col=False)

In [8]:
emissions.head()


Out[8]:
State Facility Name Facility ID (ORISPL) Unit ID Associated Stacks Month Year Program(s) Operating Time Gross Load (MW-h) Steam Load (1000lb) SO2 (tons) Avg. NOx Rate (lb/MMBtu) NOx (tons) CO2 (short tons) Heat Input (MMBtu) EPA Region NERC Region Unit Type Fuel Type (Primary)
0 AL AMEA Sylacauga Plant 56018 1 NaN 5 2016 CSNOX, CSNOXOS, CSSO2G2, ARP 28.00 1149.0 NaN 0.004 0.0759 0.473 732.800 12428.200 4 SERC Combustion turbine Pipeline Natural Gas
1 AL AMEA Sylacauga Plant 56018 2 NaN 5 2016 CSNOX, CSNOXOS, CSSO2G2, ARP 17.00 642.0 NaN 0.002 0.0809 0.283 412.300 6984.600 4 SERC Combustion turbine Pipeline Natural Gas
2 AL Barry 3 1 CS0AAN 5 2016 ARP, CSNOX, CSNOXOS, CSSO2G2 2.75 11.0 NaN 0.005 0.0080 0.001 14.213 240.050 4 SERC Tangentially-fired Pipeline Natural Gas
3 AL Barry 3 2 CS0AAN 5 2016 ARP, CSNOX, CSNOXOS, CSSO2G2 2.75 11.0 NaN 0.005 0.0080 0.001 14.213 240.050 4 SERC Tangentially-fired Pipeline Natural Gas
4 AL Barry 3 4 NaN 5 2016 ARP, MATS, CSNOX, CSNOXOS, CSSO2G2 725.25 116336.0 NaN 572.537 0.4319 265.224 128402.000 1251483.675 4 SERC Tangentially-fired Coal

In [9]:
emissions.tail()


Out[9]:
State Facility Name Facility ID (ORISPL) Unit ID Associated Stacks Month Year Program(s) Operating Time Gross Load (MW-h) Steam Load (1000lb) SO2 (tons) Avg. NOx Rate (lb/MMBtu) NOx (tons) CO2 (short tons) Heat Input (MMBtu) EPA Region NERC Region Unit Type Fuel Type (Primary)
3919 WY Neil Simpson II (CT2) 55477 CT2 NaN 5 2016 ARP 2.16 69.00 NaN 0.000 0.0485 0.020 39.911 672.960 8 NaN Combustion turbine Pipeline Natural Gas
3920 WY Wygen I 55479 001 NaN 5 2016 ARP, MATS 662.62 58852.88 NaN 24.672 0.1298 43.135 68889.530 656851.004 8 NaN Dry bottom wall-fired boiler Coal
3921 WY Wygen II 56319 001 NaN 5 2016 ARP, MATS 744.00 69215.00 NaN 17.378 0.0534 20.303 79420.900 757259.300 8 WECC Dry bottom wall-fired boiler Coal
3922 WY Wygen III 56596 001 NaN 5 2016 ARP, MATS 581.64 62642.20 NaN 16.041 0.0481 12.642 67689.944 645401.544 8 WECC Dry bottom wall-fired boiler Coal
3923 WY Wyodak 6101 BW91 NaN 5 2016 ARP, MATS 0.00 NaN NaN NaN NaN NaN NaN NaN 8 WECC Dry bottom wall-fired boiler Coal

Access parts of the dataframe


In [10]:
emissions.columns


Out[10]:
Index([u'State', u' Facility Name', u' Facility ID (ORISPL)', u' Unit ID',
       u' Associated Stacks', u' Month', u' Year', u' Program(s)',
       u' Operating Time', u' Gross Load (MW-h)', u' Steam Load (1000lb)',
       u' SO2 (tons)', u' Avg. NOx Rate (lb/MMBtu)', u' NOx (tons)',
       u' CO2 (short tons)', u' Heat Input (MMBtu)', u' EPA Region',
       u' NERC Region', u' Unit Type', u' Fuel Type (Primary)'],
      dtype='object')

In [12]:
emissions.columns = [name.strip() for name in emissions.columns]

In [13]:
emissions.columns


Out[13]:
Index([u'State', u'Facility Name', u'Facility ID (ORISPL)', u'Unit ID',
       u'Associated Stacks', u'Month', u'Year', u'Program(s)',
       u'Operating Time', u'Gross Load (MW-h)', u'Steam Load (1000lb)',
       u'SO2 (tons)', u'Avg. NOx Rate (lb/MMBtu)', u'NOx (tons)',
       u'CO2 (short tons)', u'Heat Input (MMBtu)', u'EPA Region',
       u'NERC Region', u'Unit Type', u'Fuel Type (Primary)'],
      dtype='object')

In [14]:
emissions.dtypes


Out[14]:
State                        object
Facility Name                object
Facility ID (ORISPL)          int64
Unit ID                      object
Associated Stacks            object
Month                         int64
Year                          int64
Program(s)                   object
Operating Time              float64
Gross Load (MW-h)           float64
Steam Load (1000lb)         float64
SO2 (tons)                  float64
Avg. NOx Rate (lb/MMBtu)    float64
NOx (tons)                  float64
CO2 (short tons)            float64
Heat Input (MMBtu)          float64
EPA Region                    int64
NERC Region                  object
Unit Type                    object
Fuel Type (Primary)          object
dtype: object

Dataframe vs Series


In [15]:
type(emissions)


Out[15]:
pandas.core.frame.DataFrame

In [16]:
type(emissions['State'])


Out[16]:
pandas.core.series.Series

Accessing parts of data


In [18]:
emissions.loc[:,'State']


Out[18]:
0       AL
1       AL
2       AL
3       AL
4       AL
5       AL
6       AL
7       AL
8       AL
9       AL
10      AL
11      AL
12      AL
13      AL
14      AL
15      AL
16      AL
17      AL
18      AL
19      AL
20      AL
21      AL
22      AL
23      AL
24      AL
25      AL
26      AL
27      AL
28      AL
29      AL
        ..
3894    WV
3895    WV
3896    WV
3897    WV
3898    WV
3899    WY
3900    WY
3901    WY
3902    WY
3903    WY
3904    WY
3905    WY
3906    WY
3907    WY
3908    WY
3909    WY
3910    WY
3911    WY
3912    WY
3913    WY
3914    WY
3915    WY
3916    WY
3917    WY
3918    WY
3919    WY
3920    WY
3921    WY
3922    WY
3923    WY
Name: State, dtype: object

In [20]:
emissions.loc[:5,'State':'Operating Time']


Out[20]:
State Facility Name Facility ID (ORISPL) Unit ID Associated Stacks Month Year Program(s) Operating Time
0 AL AMEA Sylacauga Plant 56018 1 NaN 5 2016 CSNOX, CSNOXOS, CSSO2G2, ARP 28.00
1 AL AMEA Sylacauga Plant 56018 2 NaN 5 2016 CSNOX, CSNOXOS, CSSO2G2, ARP 17.00
2 AL Barry 3 1 CS0AAN 5 2016 ARP, CSNOX, CSNOXOS, CSSO2G2 2.75
3 AL Barry 3 2 CS0AAN 5 2016 ARP, CSNOX, CSNOXOS, CSSO2G2 2.75
4 AL Barry 3 4 NaN 5 2016 ARP, MATS, CSNOX, CSNOXOS, CSSO2G2 725.25
5 AL Barry 3 5 MS5C, MS5D, MS5E 5 2016 ARP, MATS, CSNOX, CSNOXOS, CSSO2G2 588.00

In [21]:
emissions.iloc[:5,:3]


Out[21]:
State Facility Name Facility ID (ORISPL)
0 AL AMEA Sylacauga Plant 56018
1 AL AMEA Sylacauga Plant 56018
2 AL Barry 3
3 AL Barry 3
4 AL Barry 3

Sum unit emissions for each facility using groupby


In [24]:
emissions.groupby('Facility ID (ORISPL)')


Out[24]:
<pandas.core.groupby.DataFrameGroupBy object at 0x11307ba50>

In [27]:
facility_emiss = emissions.groupby('Facility ID (ORISPL)').sum()
facility_emiss


Out[27]:
Month Year Operating Time Gross Load (MW-h) Steam Load (1000lb) SO2 (tons) Avg. NOx Rate (lb/MMBtu) NOx (tons) CO2 (short tons) Heat Input (MMBtu) EPA Region
Facility ID (ORISPL)
3 40 16128 3844.00 1048450.25 NaN 595.911 0.5760 411.165 677078.976 8471790.125 32
7 10 4032 924.00 NaN 222159.75 0.990 0.2067 13.814 15771.300 266053.425 8
8 15 6048 1837.25 505777.25 NaN 125.662 0.5375 440.348 531418.603 5179513.525 12
9 5 2016 20.60 541.68 NaN 0.003 0.2751 1.504 NaN 10441.833 6
10 55 22176 188.25 8897.75 NaN 48.579 0.8474 10.162 11340.124 144258.150 44
26 25 10080 744.00 495791.00 NaN 173.698 0.0646 165.370 524604.900 5113099.400 20
47 65 26208 20.00 177.00 NaN 0.333 4.4379 0.722 192.400 2765.600 52
50 10 4032 0.00 NaN NaN NaN NaN NaN NaN NaN 8
51 5 2016 553.48 262392.63 NaN 1081.656 0.2080 241.863 270128.775 2481213.560 6
54 45 18144 254.45 15652.65 NaN 0.057 0.3753 2.787 11101.898 186799.693 36
56 15 6048 759.23 112793.47 NaN 63.902 0.5125 167.878 129301.129 1260257.488 12
59 5 2016 321.07 18822.00 NaN 16.264 0.2297 24.957 21946.742 209245.816 7
60 10 4032 753.95 36111.00 NaN 176.503 0.2169 39.165 44877.292 427905.242 14
87 5 2016 744.00 82439.00 NaN 34.069 0.3811 161.168 88806.200 846735.000 6
108 5 2016 660.18 160882.24 NaN 95.013 0.1813 151.412 173507.748 1654354.527 7
113 15 6048 992.93 120001.76 NaN 57.635 0.6462 149.985 135364.206 1319344.965 27
116 10 4032 247.40 8653.84 NaN 0.032 0.2216 7.130 6368.940 107186.519 18
117 15 6048 623.34 109950.39 NaN 0.257 0.0754 7.739 50958.633 857449.725 27
118 5 2016 37.80 1491.10 NaN 0.007 0.0507 0.447 1333.907 22445.386 9
120 15 6048 748.53 35334.66 NaN 0.120 0.1839 26.270 23956.571 403122.659 27
124 5 2016 7.70 360.90 NaN 0.009 0.0468 0.081 298.620 5024.270 9
126 20 8064 1101.56 76803.54 NaN 2.119 0.5604 69.574 50133.139 822072.677 36
127 5 2016 401.58 129794.52 NaN 73.983 0.2907 203.293 145337.271 1385756.804 6
130 20 8064 1518.03 822856.12 NaN 370.759 0.2077 289.871 860955.931 8391402.264 16
136 10 4032 1451.60 689645.88 NaN 477.829 0.1152 187.062 682395.436 6651035.344 8
141 15 6048 67.49 4296.61 NaN 0.014 0.5300 11.359 2730.960 45960.324 27
147 5 2016 611.23 130042.08 NaN 0.277 0.0101 3.965 54824.884 922519.859 9
160 20 8064 1970.04 185441.25 NaN 20.620 1.0331 359.939 185387.782 1905952.909 36
165 10 4032 603.34 191538.88 NaN 506.266 0.2807 170.876 239423.987 2290169.297 12
170 5 2016 638.74 139956.89 NaN 0.422 0.2584 239.594 83529.374 1405547.366 6
... ... ... ... ... ... ... ... ... ... ... ...
57037 10 4032 1398.25 368847.25 NaN 0.850 0.0271 17.634 168415.150 2833845.350 8
57073 5 2016 0.00 NaN NaN NaN NaN NaN NaN NaN 9
57074 5 2016 407.00 NaN NaN 0.015 0.0110 0.298 3187.900 54046.000 9
57075 5 2016 248.00 NaN NaN 0.007 0.0110 0.149 1602.200 27151.000 9
57241 5 2016 42.34 2051.00 NaN 0.090 0.0555 1.154 3480.042 33986.189 4
57267 20 8064 18.74 2488.57 NaN 0.008 0.0434 0.123 1712.645 28817.647 36
57349 5 2016 393.61 100963.68 NaN 0.207 0.0089 2.387 40922.021 688589.496 3
57482 40 16128 451.97 29914.41 NaN 0.088 0.1731 2.092 17568.752 295618.850 72
57483 20 8064 345.92 10334.14 NaN 0.036 0.0692 0.712 6236.594 104945.273 36
57515 25 10080 823.60 65754.07 NaN 0.174 0.1513 5.561 34605.858 582304.228 45
57703 15 6048 733.14 19706.25 NaN 0.060 0.0540 0.859 12035.438 202527.156 24
57839 10 4032 1101.30 357284.80 NaN 0.639 0.0110 5.838 126516.225 2128891.010 4
57865 15 6048 81.55 10928.02 NaN 0.034 0.1633 2.704 6779.163 114074.151 18
57881 15 6048 580.92 20205.20 NaN 0.062 0.0855 1.784 12307.201 207098.166 24
57943 15 6048 1753.37 60954.81 NaN 0.183 0.0481 3.916 36090.079 607288.728 24
57978 5 2016 16.81 2461.69 NaN 0.008 0.0201 0.119 1625.035 27347.542 9
58001 20 8064 1485.62 417253.89 NaN 0.935 0.0426 12.778 185161.751 3115749.902 24
58005 10 4032 994.60 292270.75 NaN 0.644 0.0166 7.113 127678.269 2148462.119 12
58054 5 2016 743.03 53385.00 NaN 1.455 0.0584 19.356 69154.702 664207.371 1
58079 10 4032 1268.00 385188.46 NaN 0.756 0.0128 7.746 149796.191 2520589.201 4
58122 5 2016 2.57 61.56 NaN 0.000 0.0775 0.048 43.560 732.625 9
58235 5 2016 119.55 7160.00 NaN 0.020 0.0191 0.384 3909.089 65770.895 2
58260 15 6048 1824.11 705418.26 NaN 1.468 0.0321 17.479 290920.901 4895295.214 9
58284 5 2016 16.62 483.78 NaN 0.001 0.0250 0.032 289.595 4874.589 6
58325 5 2016 7.93 471.64 NaN 0.002 0.0457 0.147 390.728 6576.714 6
58471 10 4032 81.30 8786.34 NaN 0.142 0.1028 1.593 6244.180 105066.232 12
58478 5 2016 47.25 1823.50 NaN 0.005 0.0215 0.148 968.200 16293.125 6
58562 10 4032 615.09 40172.06 NaN 0.111 0.0296 2.077 21929.390 368989.001 12
59926 10 4032 24.63 2794.92 NaN 0.015 0.0320 0.806 2972.500 50368.700 10
70454 10 4032 62.78 7178.74 NaN 0.026 0.1711 3.388 5164.599 86899.023 8

1208 rows × 11 columns

Use apply to apply a function to every row of the dataframe


In [31]:
def correct_region(row):
    num_units = row['Month'] / 5
    region = row['EPA Region'] / num_units
    return int(region)

In [33]:
facility_emiss.loc[:,'EPA Region'] = facility_emiss.apply(correct_region, axis=1)
facility_emiss = facility_emiss.iloc[:,2:]
facility_emiss


Out[33]:
Operating Time Gross Load (MW-h) Steam Load (1000lb) SO2 (tons) Avg. NOx Rate (lb/MMBtu) NOx (tons) CO2 (short tons) Heat Input (MMBtu) EPA Region
Facility ID (ORISPL)
3 3844.00 1048450.25 NaN 595.911 0.5760 411.165 677078.976 8471790.125 4
7 924.00 NaN 222159.75 0.990 0.2067 13.814 15771.300 266053.425 4
8 1837.25 505777.25 NaN 125.662 0.5375 440.348 531418.603 5179513.525 4
9 20.60 541.68 NaN 0.003 0.2751 1.504 NaN 10441.833 6
10 188.25 8897.75 NaN 48.579 0.8474 10.162 11340.124 144258.150 4
26 744.00 495791.00 NaN 173.698 0.0646 165.370 524604.900 5113099.400 4
47 20.00 177.00 NaN 0.333 4.4379 0.722 192.400 2765.600 4
50 0.00 NaN NaN NaN NaN NaN NaN NaN 4
51 553.48 262392.63 NaN 1081.656 0.2080 241.863 270128.775 2481213.560 6
54 254.45 15652.65 NaN 0.057 0.3753 2.787 11101.898 186799.693 4
56 759.23 112793.47 NaN 63.902 0.5125 167.878 129301.129 1260257.488 4
59 321.07 18822.00 NaN 16.264 0.2297 24.957 21946.742 209245.816 7
60 753.95 36111.00 NaN 176.503 0.2169 39.165 44877.292 427905.242 7
87 744.00 82439.00 NaN 34.069 0.3811 161.168 88806.200 846735.000 6
108 660.18 160882.24 NaN 95.013 0.1813 151.412 173507.748 1654354.527 7
113 992.93 120001.76 NaN 57.635 0.6462 149.985 135364.206 1319344.965 9
116 247.40 8653.84 NaN 0.032 0.2216 7.130 6368.940 107186.519 9
117 623.34 109950.39 NaN 0.257 0.0754 7.739 50958.633 857449.725 9
118 37.80 1491.10 NaN 0.007 0.0507 0.447 1333.907 22445.386 9
120 748.53 35334.66 NaN 0.120 0.1839 26.270 23956.571 403122.659 9
124 7.70 360.90 NaN 0.009 0.0468 0.081 298.620 5024.270 9
126 1101.56 76803.54 NaN 2.119 0.5604 69.574 50133.139 822072.677 9
127 401.58 129794.52 NaN 73.983 0.2907 203.293 145337.271 1385756.804 6
130 1518.03 822856.12 NaN 370.759 0.2077 289.871 860955.931 8391402.264 4
136 1451.60 689645.88 NaN 477.829 0.1152 187.062 682395.436 6651035.344 4
141 67.49 4296.61 NaN 0.014 0.5300 11.359 2730.960 45960.324 9
147 611.23 130042.08 NaN 0.277 0.0101 3.965 54824.884 922519.859 9
160 1970.04 185441.25 NaN 20.620 1.0331 359.939 185387.782 1905952.909 9
165 603.34 191538.88 NaN 506.266 0.2807 170.876 239423.987 2290169.297 6
170 638.74 139956.89 NaN 0.422 0.2584 239.594 83529.374 1405547.366 6
... ... ... ... ... ... ... ... ... ...
57037 1398.25 368847.25 NaN 0.850 0.0271 17.634 168415.150 2833845.350 4
57073 0.00 NaN NaN NaN NaN NaN NaN NaN 9
57074 407.00 NaN NaN 0.015 0.0110 0.298 3187.900 54046.000 9
57075 248.00 NaN NaN 0.007 0.0110 0.149 1602.200 27151.000 9
57241 42.34 2051.00 NaN 0.090 0.0555 1.154 3480.042 33986.189 4
57267 18.74 2488.57 NaN 0.008 0.0434 0.123 1712.645 28817.647 9
57349 393.61 100963.68 NaN 0.207 0.0089 2.387 40922.021 688589.496 3
57482 451.97 29914.41 NaN 0.088 0.1731 2.092 17568.752 295618.850 9
57483 345.92 10334.14 NaN 0.036 0.0692 0.712 6236.594 104945.273 9
57515 823.60 65754.07 NaN 0.174 0.1513 5.561 34605.858 582304.228 9
57703 733.14 19706.25 NaN 0.060 0.0540 0.859 12035.438 202527.156 8
57839 1101.30 357284.80 NaN 0.639 0.0110 5.838 126516.225 2128891.010 2
57865 81.55 10928.02 NaN 0.034 0.1633 2.704 6779.163 114074.151 6
57881 580.92 20205.20 NaN 0.062 0.0855 1.784 12307.201 207098.166 8
57943 1753.37 60954.81 NaN 0.183 0.0481 3.916 36090.079 607288.728 8
57978 16.81 2461.69 NaN 0.008 0.0201 0.119 1625.035 27347.542 9
58001 1485.62 417253.89 NaN 0.935 0.0426 12.778 185161.751 3115749.902 6
58005 994.60 292270.75 NaN 0.644 0.0166 7.113 127678.269 2148462.119 6
58054 743.03 53385.00 NaN 1.455 0.0584 19.356 69154.702 664207.371 1
58079 1268.00 385188.46 NaN 0.756 0.0128 7.746 149796.191 2520589.201 2
58122 2.57 61.56 NaN 0.000 0.0775 0.048 43.560 732.625 9
58235 119.55 7160.00 NaN 0.020 0.0191 0.384 3909.089 65770.895 2
58260 1824.11 705418.26 NaN 1.468 0.0321 17.479 290920.901 4895295.214 3
58284 16.62 483.78 NaN 0.001 0.0250 0.032 289.595 4874.589 6
58325 7.93 471.64 NaN 0.002 0.0457 0.147 390.728 6576.714 6
58471 81.30 8786.34 NaN 0.142 0.1028 1.593 6244.180 105066.232 6
58478 47.25 1823.50 NaN 0.005 0.0215 0.148 968.200 16293.125 6
58562 615.09 40172.06 NaN 0.111 0.0296 2.077 21929.390 368989.001 6
59926 24.63 2794.92 NaN 0.015 0.0320 0.806 2972.500 50368.700 5
70454 62.78 7178.74 NaN 0.026 0.1711 3.388 5164.599 86899.023 4

1208 rows × 9 columns

Load capacity data


In [34]:
capacity = pd.read_excel(fn2, sheetname='Operating', header=1)

In [35]:
capacity.head()


Out[35]:
Entity ID Entity Name Plant ID Plant Name Sector Plant State Generator ID Nameplate Capacity (MW) Net Summer Capacity (MW) Technology ... Status Planned Derate Year Planned Derate Month Planned Derate of Summer Capacity (MW) Planned Uprate Year Planned Uprate Month Planned Uprate of Summer Capacity (MW) County Latitude Longitude
0 195 Alabama Power Co 2.0 Bankhead Dam Electric Utility AL 1 53.9 56 Conventional Hydroelectric ... (OP) Operating Tuscaloosa 33.4587 -87.3568
1 195 Alabama Power Co 3.0 Barry Electric Utility AL 1 153.1 55 Natural Gas Steam Turbine ... (OP) Operating Mobile 31.0069 -88.0103
2 195 Alabama Power Co 3.0 Barry Electric Utility AL 2 153.1 55 Natural Gas Steam Turbine ... (OP) Operating Mobile 31.0069 -88.0103
3 195 Alabama Power Co 3.0 Barry Electric Utility AL 4 403.7 362 Conventional Steam Coal ... (OP) Operating Mobile 31.0069 -88.0103
4 195 Alabama Power Co 3.0 Barry Electric Utility AL 5 788.8 726.5 Conventional Steam Coal ... (OP) Operating Mobile 31.0069 -88.0103

5 rows × 26 columns


In [36]:
capacity.tail()


Out[36]:
Entity ID Entity Name Plant ID Plant Name Sector Plant State Generator ID Nameplate Capacity (MW) Net Summer Capacity (MW) Technology ... Status Planned Derate Year Planned Derate Month Planned Derate of Summer Capacity (MW) Planned Uprate Year Planned Uprate Month Planned Uprate of Summer Capacity (MW) County Latitude Longitude
20183 60205 Currin Solar, LLC 60403.0 Currin Solar, LLC IPP Non-CHP NC CSPV 5.2 5.2 Solar Photovoltaic ... (OP) Operating Granville 36.2896 -78.6333
20184 60163 Soltage LLC 60411.0 Coventry Photovoltaic, LLC IPP Non-CHP VT COVEN 2.2 2.2 Solar Photovoltaic ... (OP) Operating Orleans 44.9102 -72.2198
20185 60227 ORNI 37 LLC 60419.0 Don A Campbell 2 Geothermal IPP Non-CHP NV DAC2G 25.0 16.2 Geothermal ... (OP) Operating Mineral 38.8358 -118.325
20186 57081 WGL Energy Systems, Inc 60425.0 Skidmore College IPP Non-CHP NY SO049 2.0 2 Solar Photovoltaic ... (OP) Operating Saratoga 43.0937 -73.8113
20187 NOTES:\nCapacity from facilities with a total ... NaN NaN NaN NaN NaN NaN NaN NaN NaN ... NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN

5 rows × 26 columns


In [37]:
capacity.drop(20187, inplace=True)

In [38]:
capacity.loc[:,'Plant ID'] = capacity.loc[:,'Plant ID'].astype(int)

In [39]:
capacity.head()


Out[39]:
Entity ID Entity Name Plant ID Plant Name Sector Plant State Generator ID Nameplate Capacity (MW) Net Summer Capacity (MW) Technology ... Status Planned Derate Year Planned Derate Month Planned Derate of Summer Capacity (MW) Planned Uprate Year Planned Uprate Month Planned Uprate of Summer Capacity (MW) County Latitude Longitude
0 195 Alabama Power Co 2 Bankhead Dam Electric Utility AL 1 53.9 56 Conventional Hydroelectric ... (OP) Operating Tuscaloosa 33.4587 -87.3568
1 195 Alabama Power Co 3 Barry Electric Utility AL 1 153.1 55 Natural Gas Steam Turbine ... (OP) Operating Mobile 31.0069 -88.0103
2 195 Alabama Power Co 3 Barry Electric Utility AL 2 153.1 55 Natural Gas Steam Turbine ... (OP) Operating Mobile 31.0069 -88.0103
3 195 Alabama Power Co 3 Barry Electric Utility AL 4 403.7 362 Conventional Steam Coal ... (OP) Operating Mobile 31.0069 -88.0103
4 195 Alabama Power Co 3 Barry Electric Utility AL 5 788.8 726.5 Conventional Steam Coal ... (OP) Operating Mobile 31.0069 -88.0103

5 rows × 26 columns

Check column names


In [40]:
capacity.columns


Out[40]:
Index([u'Entity ID', u'Entity Name', u'Plant ID', u'Plant Name', u'Sector',
       u'Plant State', u'Generator ID', u'\nNameplate Capacity (MW)',
       u'\n \nNet Summer Capacity (MW)', u'Technology', u'Energy Source Code',
       u'Prime Mover Code', u'Operating Month', u'Operating Year',
       u'Planned Retirement Month', u'Planned Retirement Year', u'Status',
       u'Planned Derate Year', u'Planned Derate Month',
       u'Planned Derate of Summer Capacity (MW)', u'Planned Uprate Year',
       u'Planned Uprate Month', u'Planned Uprate of Summer Capacity (MW)',
       u'County', u'Latitude', u'Longitude'],
      dtype='object')

In [41]:
capacity.columns = [name.strip() for name in capacity.columns]

In [42]:
capacity.columns


Out[42]:
Index([u'Entity ID', u'Entity Name', u'Plant ID', u'Plant Name', u'Sector',
       u'Plant State', u'Generator ID', u'Nameplate Capacity (MW)',
       u'Net Summer Capacity (MW)', u'Technology', u'Energy Source Code',
       u'Prime Mover Code', u'Operating Month', u'Operating Year',
       u'Planned Retirement Month', u'Planned Retirement Year', u'Status',
       u'Planned Derate Year', u'Planned Derate Month',
       u'Planned Derate of Summer Capacity (MW)', u'Planned Uprate Year',
       u'Planned Uprate Month', u'Planned Uprate of Summer Capacity (MW)',
       u'County', u'Latitude', u'Longitude'],
      dtype='object')

Boolean filtering


In [43]:
PA_cap = capacity.loc[capacity['Plant State']=='PA',:]
PA_cap


Out[43]:
Entity ID Entity Name Plant ID Plant Name Sector Plant State Generator ID Nameplate Capacity (MW) Net Summer Capacity (MW) Technology ... Status Planned Derate Year Planned Derate Month Planned Derate of Summer Capacity (MW) Planned Uprate Year Planned Uprate Month Planned Uprate of Summer Capacity (MW) County Latitude Longitude
5223 14165 NRG Power Midwest LP 3096 Brunot Island IPP Non-CHP PA 1A 25.5 15 Petroleum Liquids ... (OP) Operating Allegheny 40.4649 -80.0438
5224 14165 NRG Power Midwest LP 3096 Brunot Island IPP Non-CHP PA 2A 65.3 46 Natural Gas Fired Combined Cycle ... (OP) Operating Allegheny 40.4649 -80.0438
5225 14165 NRG Power Midwest LP 3096 Brunot Island IPP Non-CHP PA 2B 65.3 48 Natural Gas Fired Combined Cycle ... (OP) Operating Allegheny 40.4649 -80.0438
5226 14165 NRG Power Midwest LP 3096 Brunot Island IPP Non-CHP PA 3 65.3 49 Natural Gas Fired Combined Cycle ... (OP) Operating Allegheny 40.4649 -80.0438
5227 14165 NRG Power Midwest LP 3096 Brunot Island IPP Non-CHP PA ST4 144.0 101 Natural Gas Fired Combined Cycle ... (OP) Operating Allegheny 40.4649 -80.0438
5228 17235 NRG REMA LLC 3109 Hamilton (PA) IPP Non-CHP PA 1 19.6 18 Petroleum Liquids ... (OP) Operating Adams 39.9087 -76.9885
5229 17235 NRG REMA LLC 3110 Hunterstown IPP Non-CHP PA 1 20.0 18 Petroleum Liquids ... (OP) Operating Adams 39.8662 -77.1648
5230 17235 NRG REMA LLC 3110 Hunterstown IPP Non-CHP PA 2 20.0 17 Petroleum Liquids ... (OP) Operating Adams 39.8662 -77.1648
5231 17235 NRG REMA LLC 3110 Hunterstown IPP Non-CHP PA 3 20.0 18 Petroleum Liquids ... (OP) Operating Adams 39.8662 -77.1648
5232 17235 NRG REMA LLC 3111 Mountain IPP Non-CHP PA 1 27.0 18 Petroleum Liquids ... (OP) Operating Cumberland 40.1229 -77.1723
5233 17235 NRG REMA LLC 3111 Mountain IPP Non-CHP PA 2 27.0 18 Petroleum Liquids ... (OP) Operating Cumberland 40.1229 -77.1723
5234 17235 NRG REMA LLC 3112 Orrtanna IPP Non-CHP PA 1 27.0 18 Petroleum Liquids ... (OP) Operating Adams 39.8442 -77.3508
5235 17235 NRG REMA LLC 3113 Portland (PA) IPP Non-CHP PA 3 18.0 13 Petroleum Liquids ... (OP) Operating Northampton 40.9102 -75.0794
5236 17235 NRG REMA LLC 3113 Portland (PA) IPP Non-CHP PA 4 20.0 17 Petroleum Liquids ... (OP) Operating Northampton 40.9102 -75.0794
5237 17235 NRG REMA LLC 3113 Portland (PA) IPP Non-CHP PA 5 156.0 134 Petroleum Liquids ... (OP) Operating Northampton 40.9102 -75.0794
5238 17235 NRG REMA LLC 3114 Shawnee (PA) IPP Non-CHP PA 1 20.0 17 Petroleum Liquids ... (OP) Operating Monroe 41.0612 -75.0582
5239 17235 NRG REMA LLC 3115 Titus IPP Non-CHP PA 4 18.0 13 Petroleum Liquids ... (OP) Operating Berks 40.3056 -75.9081
5240 17235 NRG REMA LLC 3115 Titus IPP Non-CHP PA 5 18.0 14 Petroleum Liquids ... (OP) Operating Berks 40.3056 -75.9081
5241 17235 NRG REMA LLC 3116 Tolna IPP Non-CHP PA 1 27.0 18 Petroleum Liquids ... (SB) Standby/Backup: available for service but... York 39.7606 -76.6353
5242 17235 NRG REMA LLC 3116 Tolna IPP Non-CHP PA 2 27.0 18 Petroleum Liquids ... (SB) Standby/Backup: available for service but... York 39.7606 -76.6353
5243 56065 York Haven Power Company LLC 3117 York Haven IPP Non-CHP PA 1 19.6 19 Conventional Hydroelectric ... (OP) Operating York 40.1136 -76.712
5244 15873 GenOn Northeast Management Company 3118 Conemaugh IPP Non-CHP PA 1 936.0 850 Conventional Steam Coal ... (OP) Operating Indiana 40.3842 -79.0611
5245 15873 GenOn Northeast Management Company 3118 Conemaugh IPP Non-CHP PA 2 936.0 850 Conventional Steam Coal ... (OP) Operating Indiana 40.3842 -79.0611
5246 15873 GenOn Northeast Management Company 3118 Conemaugh IPP Non-CHP PA A 3.0 2.8 Petroleum Liquids ... (SB) Standby/Backup: available for service but... Indiana 40.3842 -79.0611
5247 15873 GenOn Northeast Management Company 3118 Conemaugh IPP Non-CHP PA B 3.0 2.8 Petroleum Liquids ... (SB) Standby/Backup: available for service but... Indiana 40.3842 -79.0611
5248 15873 GenOn Northeast Management Company 3118 Conemaugh IPP Non-CHP PA C 3.0 2.8 Petroleum Liquids ... (SB) Standby/Backup: available for service but... Indiana 40.3842 -79.0611
5249 15873 GenOn Northeast Management Company 3118 Conemaugh IPP Non-CHP PA D 3.0 2.8 Petroleum Liquids ... (SB) Standby/Backup: available for service but... Indiana 40.3842 -79.0611
5250 17235 NRG REMA LLC 3120 Blossburg IPP Non-CHP PA 1 24.0 16 Natural Gas Fired Combustion Turbine ... (OP) Operating Tioga 41.7065 -77.0818
5251 58615 NRG Homer City Services LLC 3122 Homer City Generating Station IPP Non-CHP PA 1 660.0 624.5 Conventional Steam Coal ... (OP) Operating Indiana 40.5128 -79.1961
5252 58615 NRG Homer City Services LLC 3122 Homer City Generating Station IPP Non-CHP PA 2 660.0 617.5 Conventional Steam Coal ... (OP) Operating Indiana 40.5128 -79.1961
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
18480 58438 Sunstream Energy LLC 58443 Martin Limestone Solar Array IPP Non-CHP PA GEN1 1.0 1 Solar Photovoltaic ... (OP) Operating Lancaster 40.1078 -76.0617
18526 58463 Dart Container Corp 58476 Dart Container Corp Industrial CHP PA LFGT1 5.6 4.6 Landfill Gas ... (OP) Operating Lancaster 40.0865 -76.176
18527 58463 Dart Container Corp 58476 Dart Container Corp Industrial CHP PA LFGT2 5.6 4.6 Landfill Gas ... (OP) Operating Lancaster 40.0865 -76.176
18549 7477 Granger Electric Co 58497 L&S Sweetners IPP Non-CHP PA GEN1 1.6 1.6 Landfill Gas ... (OP) Operating Lancaster 40.0906 -76.1456
18550 7477 Granger Electric Co 58497 L&S Sweetners IPP Non-CHP PA GEN2 1.6 1.6 Landfill Gas ... (OP) Operating Lancaster 40.0906 -76.1456
18598 56645 Aqua America Inc 58535 Pickering Solar IPP Non-CHP PA 1 1.5 1.4 Solar Photovoltaic ... (OP) Operating Chester 40.1206 -75.4881
18645 58527 Gettysburg Energy and Nutrient Rec Facility LLC 58565 Gettysburg Energy & Nutrient Rec Facility IPP Non-CHP PA GENRF 3.3 2.5 Other Waste Biomass ... (OP) Operating Adams 39.9503 -77.1253
18785 58617 Mahoning Creek Hydroelectric Company LLC 58685 Mahoning Creek Hydroelectric Project IPP Non-CHP PA 8107 6.0 6.7 Conventional Hydroelectric ... (OP) Operating Armstrong 40.9211 -79.2817
18818 58652 Roundtop Energy LLC 58715 Roundtop IPP Non-CHP PA GEN1 4.4 4.2 Natural Gas Internal Combustion Engine ... (OP) Operating Susquehanna 41.6578 -76.0492
18819 58652 Roundtop Energy LLC 58715 Roundtop IPP Non-CHP PA GEN2 4.4 4.2 Natural Gas Internal Combustion Engine ... (OP) Operating Susquehanna 41.6578 -76.0492
18820 58652 Roundtop Energy LLC 58715 Roundtop IPP Non-CHP PA GEN3 4.4 4.2 Natural Gas Internal Combustion Engine ... (OP) Operating Susquehanna 41.6578 -76.0492
18821 58652 Roundtop Energy LLC 58715 Roundtop IPP Non-CHP PA GEN4 4.4 4.2 Natural Gas Internal Combustion Engine ... (OP) Operating Susquehanna 41.6578 -76.0492
18822 58652 Roundtop Energy LLC 58715 Roundtop IPP Non-CHP PA GEN5 4.4 4.2 Natural Gas Internal Combustion Engine ... (OP) Operating Susquehanna 41.6578 -76.0492
19003 58767 Temple University 58897 Temple SEGF Commercial Non-CHP PA 19G01 1.6 1.6 Natural Gas Internal Combustion Engine ... (OP) Operating Philadelphia 39.98 -75.1506
19004 58767 Temple University 58897 Temple SEGF Commercial Non-CHP PA 19G02 1.6 1.6 Natural Gas Internal Combustion Engine ... (OP) Operating Philadelphia 39.98 -75.1506
19005 58767 Temple University 58897 Temple SEGF Commercial Non-CHP PA 19G03 1.6 1.6 Natural Gas Internal Combustion Engine ... (OP) Operating Philadelphia 39.98 -75.1506
19006 58767 Temple University 58897 Temple SEGF Commercial Non-CHP PA 19G04 1.6 1.6 Natural Gas Internal Combustion Engine ... (OP) Operating Philadelphia 39.98 -75.1506
19007 58767 Temple University 58897 Temple SEGF Commercial Non-CHP PA 19G05 1.6 1.6 Natural Gas Internal Combustion Engine ... (OP) Operating Philadelphia 39.98 -75.1506
19008 58767 Temple University 58897 Temple SEGF Commercial Non-CHP PA 19G06 1.6 1.6 Natural Gas Internal Combustion Engine ... (OP) Operating Philadelphia 39.98 -75.1506
19009 58767 Temple University 58897 Temple SEGF Commercial Non-CHP PA 19G07 1.6 1.6 Natural Gas Internal Combustion Engine ... (OP) Operating Philadelphia 39.98 -75.1506
19010 58767 Temple University 58897 Temple SEGF Commercial Non-CHP PA 19G08 1.6 1.6 Natural Gas Internal Combustion Engine ... (OP) Operating Philadelphia 39.98 -75.1506
19011 58767 Temple University 58897 Temple SEGF Commercial Non-CHP PA 19G09 1.6 1.6 Natural Gas Internal Combustion Engine ... (OP) Operating Philadelphia 39.98 -75.1506
19012 58767 Temple University 58897 Temple SEGF Commercial Non-CHP PA 19G10 1.6 1.6 Natural Gas Internal Combustion Engine ... (OP) Operating Philadelphia 39.98 -75.1506
19202 57130 Janssen Pharmaceutical Co 59056 Spring House IPP Non-CHP PA GEN 1 3.8 3.8 Natural Gas Internal Combustion Engine ... (OP) Operating Montgomery 40.1839 -75.2342
19435 59125 Marlboro Mushroom 59327 Marlboro Mushrooms Solar Field Industrial Non-CHP PA GEN1 1.0 1 Solar Photovoltaic ... (OP) Operating Chester 39.8828 -75.8294
19636 59287 Laurel Capital Partners 59546 Beaver Solar LLC IPP Non-CHP PA PV1 1.3 1.3 Solar Photovoltaic ... (OP) Operating Beaver 40.6914 -80.3239
19822 59526 State Correctnl Inst Laurel Highlands 59759 Glades Pike Generation Plant Commercial Non-CHP PA CAT1 1.6 1.4 Landfill Gas ... (OP) Operating Somerset 40.0067 -79.041
19823 59526 State Correctnl Inst Laurel Highlands 59759 Glades Pike Generation Plant Commercial Non-CHP PA CAT2 1.6 1.4 Landfill Gas ... (OP) Operating Somerset 40.0067 -79.041
19824 59526 State Correctnl Inst Laurel Highlands 59759 Glades Pike Generation Plant Commercial Non-CHP PA SOLAR 3.3 1.5 Landfill Gas ... (OP) Operating Somerset 40.0067 -79.041
20180 60187 Granger Energy of Morgantown 60388 Granger Energy of Morgantown IPP Non-CHP PA GEMT 1.6 1.6 Landfill Gas ... (OP) Operating Berks 40.1746 -75.9137

568 rows × 26 columns


In [46]:
PA_cap.describe()


Out[46]:
Plant ID Nameplate Capacity (MW) Operating Month Operating Year
count 568.000000 568.000000 568.000000 568.000000
mean 35621.582746 81.443310 6.195423 1987.869718
std 25038.182319 203.914129 3.563807 23.276513
min 3096.000000 0.300000 1.000000 1905.000000
25% 3170.000000 1.600000 3.000000 1971.000000
50% 52149.000000 10.400000 6.000000 1995.000000
75% 56687.000000 57.600000 10.000000 2004.000000
max 60388.000000 1377.000000 12.000000 2016.000000

In [48]:
capacity.loc[(capacity['Plant State']=='PA') & 
            (capacity['Technology']=='Natural Gas Fired Combined Cycle'),:]


Out[48]:
Entity ID Entity Name Plant ID Plant Name Sector Plant State Generator ID Nameplate Capacity (MW) Net Summer Capacity (MW) Technology ... Status Planned Derate Year Planned Derate Month Planned Derate of Summer Capacity (MW) Planned Uprate Year Planned Uprate Month Planned Uprate of Summer Capacity (MW) County Latitude Longitude
5224 14165 NRG Power Midwest LP 3096 Brunot Island IPP Non-CHP PA 2A 65.3 46 Natural Gas Fired Combined Cycle ... (OP) Operating Allegheny 40.4649 -80.0438
5225 14165 NRG Power Midwest LP 3096 Brunot Island IPP Non-CHP PA 2B 65.3 48 Natural Gas Fired Combined Cycle ... (OP) Operating Allegheny 40.4649 -80.0438
5226 14165 NRG Power Midwest LP 3096 Brunot Island IPP Non-CHP PA 3 65.3 49 Natural Gas Fired Combined Cycle ... (OP) Operating Allegheny 40.4649 -80.0438
5227 14165 NRG Power Midwest LP 3096 Brunot Island IPP Non-CHP PA ST4 144.0 101 Natural Gas Fired Combined Cycle ... (OP) Operating Allegheny 40.4649 -80.0438
5381 19391 UGI Development Co 3176 Hunlock Power Station IPP Non-CHP PA 3 49.9 30.1 Natural Gas Fired Combined Cycle ... (OP) Operating Luzerne 41.2006 -76.07
5382 19391 UGI Development Co 3176 Hunlock Power Station IPP Non-CHP PA 5 48.0 48.7 Natural Gas Fired Combined Cycle ... (OP) Operating Luzerne 41.2006 -76.07
5383 19391 UGI Development Co 3176 Hunlock Power Station IPP Non-CHP PA 6 48.0 48.4 Natural Gas Fired Combined Cycle ... (OP) Operating Luzerne 41.2006 -76.07
11869 2468 Bucknell University 54333 Bucknell University Commercial CHP PA G001 4.7 4.3 Natural Gas Fired Combined Cycle ... (OP) Operating Union 40.955 -76.8788
11870 2468 Bucknell University 54333 Bucknell University Commercial CHP PA G502 1.2 0.5 Natural Gas Fired Combined Cycle ... (OP) Operating Union 40.955 -76.8788
12320 56516 Morris Energy Operations Company, LLC 54693 York Generation Company LLC IPP Non-CHP PA GT#1 8.3 46.2 Natural Gas Fired Combined Cycle ... (OP) Operating York 39.9856 -76.6762
12321 56516 Morris Energy Operations Company, LLC 54693 York Generation Company LLC IPP Non-CHP PA GT#2 8.3 Natural Gas Fired Combined Cycle ... (OP) Operating York 39.9856 -76.6762
12322 56516 Morris Energy Operations Company, LLC 54693 York Generation Company LLC IPP Non-CHP PA GT#5 8.3 Natural Gas Fired Combined Cycle ... (OP) Operating York 39.9856 -76.6762
12323 56516 Morris Energy Operations Company, LLC 54693 York Generation Company LLC IPP Non-CHP PA GT#6 8.3 Natural Gas Fired Combined Cycle ... (OP) Operating York 39.9856 -76.6762
12324 56516 Morris Energy Operations Company, LLC 54693 York Generation Company LLC IPP Non-CHP PA ST#1 9.5 Natural Gas Fired Combined Cycle ... (OP) Operating York 39.9856 -76.6762
12325 56516 Morris Energy Operations Company, LLC 54693 York Generation Company LLC IPP Non-CHP PA ST#2 9.5 Natural Gas Fired Combined Cycle ... (OP) Operating York 39.9856 -76.6762
12528 7564 Grays Ferry Cogen Partnership 54785 Grays Ferry Cogeneration IPP CHP PA GEN1 57.6 57 Natural Gas Fired Combined Cycle ... (OP) Operating Philadelphia 39.9422 -75.1881
12529 7564 Grays Ferry Cogen Partnership 54785 Grays Ferry Cogeneration IPP CHP PA GEN2 135.0 113 Natural Gas Fired Combined Cycle ... (OP) Operating Philadelphia 39.9422 -75.1881
13268 55649 Ontelaunee Energy Center 55193 Ontelaunee Energy Center IPP Non-CHP PA CTG1 250.0 180 Natural Gas Fired Combined Cycle ... (OP) Operating Berks 40.4219 -75.9356
13269 55649 Ontelaunee Energy Center 55193 Ontelaunee Energy Center IPP Non-CHP PA CTG2 250.0 180 Natural Gas Fired Combined Cycle ... (OP) Operating Berks 40.4219 -75.9356
13270 55649 Ontelaunee Energy Center 55193 Ontelaunee Energy Center IPP Non-CHP PA STG 228.0 180 Natural Gas Fired Combined Cycle ... (OP) Operating Berks 40.4219 -75.9356
13389 27031 Liberty Electric Power LLC 55231 Liberty Electric Power Plant IPP Non-CHP PA GTG1 186.0 158.6 Natural Gas Fired Combined Cycle ... (OP) Operating 2017 4 10.5 Delaware 39.8614 -75.3358
13390 27031 Liberty Electric Power LLC 55231 Liberty Electric Power Plant IPP Non-CHP PA GTG2 186.0 158.6 Natural Gas Fired Combined Cycle ... (OP) Operating 2016 10 10.5 Delaware 39.8614 -75.3358
13391 27031 Liberty Electric Power LLC 55231 Liberty Electric Power Plant IPP Non-CHP PA STG 242.0 223.8 Natural Gas Fired Combined Cycle ... (OP) Operating Delaware 39.8614 -75.3358
13604 54817 Fairless Energy LLC 55298 Fairless Energy Center IPP Non-CHP PA CT1A 198.9 189 Natural Gas Fired Combined Cycle ... (OP) Operating Bucks 40.1475 -74.7411
13605 54817 Fairless Energy LLC 55298 Fairless Energy Center IPP Non-CHP PA CT1B 198.9 189 Natural Gas Fired Combined Cycle ... (OP) Operating Bucks 40.1475 -74.7411
13606 54817 Fairless Energy LLC 55298 Fairless Energy Center IPP Non-CHP PA CT2A 198.9 189 Natural Gas Fired Combined Cycle ... (OP) Operating Bucks 40.1475 -74.7411
13607 54817 Fairless Energy LLC 55298 Fairless Energy Center IPP Non-CHP PA CT2B 198.9 189 Natural Gas Fired Combined Cycle ... (OP) Operating Bucks 40.1475 -74.7411
13608 54817 Fairless Energy LLC 55298 Fairless Energy Center IPP Non-CHP PA ST1 271.2 258 Natural Gas Fired Combined Cycle ... (OP) Operating Bucks 40.1475 -74.7411
13609 54817 Fairless Energy LLC 55298 Fairless Energy Center IPP Non-CHP PA ST2 271.2 258 Natural Gas Fired Combined Cycle ... (OP) Operating Bucks 40.1475 -74.7411
13674 58199 TalenEnergy Ironwood LLC 55337 TalenEnergy Ironwood LLC IPP Non-CHP PA CT1 259.2 218.7 Natural Gas Fired Combined Cycle ... (OP) Operating Lebanon 40.3509 -76.3658
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
13676 58199 TalenEnergy Ironwood LLC 55337 TalenEnergy Ironwood LLC IPP Non-CHP PA ST4 259.2 219.7 Natural Gas Fired Combined Cycle ... (OP) Operating Lebanon 40.3509 -76.3658
13964 59923 Dynegy Fayette Energy Facility 55516 Fayette Energy Facility IPP Non-CHP PA CTG1 163.5 174 Natural Gas Fired Combined Cycle ... (OP) Operating Fayette 39.8592 -79.9182
13965 59923 Dynegy Fayette Energy Facility 55516 Fayette Energy Facility IPP Non-CHP PA CTG2 163.5 174 Natural Gas Fired Combined Cycle ... (OP) Operating Fayette 39.8592 -79.9182
13966 59923 Dynegy Fayette Energy Facility 55516 Fayette Energy Facility IPP Non-CHP PA STG1 317.1 314 Natural Gas Fired Combined Cycle ... (OP) Operating Fayette 39.8592 -79.9182
13986 56608 Calpine Mid-Merit LLC 55524 York Energy Center IPP Non-CHP PA CTG1 120.0 113 Natural Gas Fired Combined Cycle ... (OP) Operating York 39.7375 -76.3067
13987 56608 Calpine Mid-Merit LLC 55524 York Energy Center IPP Non-CHP PA CTG2 120.0 122 Natural Gas Fired Combined Cycle ... (OP) Operating York 39.7375 -76.3067
13988 56608 Calpine Mid-Merit LLC 55524 York Energy Center IPP Non-CHP PA CTG3 120.0 122 Natural Gas Fired Combined Cycle ... (OP) Operating York 39.7375 -76.3067
13989 56608 Calpine Mid-Merit LLC 55524 York Energy Center IPP Non-CHP PA STG1 200.0 188 Natural Gas Fired Combined Cycle ... (OP) Operating York 39.7375 -76.3067
14161 11275 Lower Mount Bethel Energy LLC 55667 Lower Mount Bethel Energy IPP Non-CHP PA G1 211.5 160.9 Natural Gas Fired Combined Cycle ... (OP) Operating Northampton 40.8019 -75.1076
14162 11275 Lower Mount Bethel Energy LLC 55667 Lower Mount Bethel Energy IPP Non-CHP PA G2 211.5 162.6 Natural Gas Fired Combined Cycle ... (OP) Operating Northampton 40.8019 -75.1076
14163 11275 Lower Mount Bethel Energy LLC 55667 Lower Mount Bethel Energy IPP Non-CHP PA G3 228.6 214 Natural Gas Fired Combined Cycle ... (OP) Operating Northampton 40.8019 -75.1076
14180 56607 Calpine Bethlehem LLC 55690 Bethlehem Power Plant IPP Non-CHP PA CTG1 127.0 118 Natural Gas Fired Combined Cycle ... (OP) Operating Northampton 40.6175 -75.3147
14181 56607 Calpine Bethlehem LLC 55690 Bethlehem Power Plant IPP Non-CHP PA CTG2 127.0 127 Natural Gas Fired Combined Cycle ... (OP) Operating Northampton 40.6175 -75.3147
14182 56607 Calpine Bethlehem LLC 55690 Bethlehem Power Plant IPP Non-CHP PA CTG3 127.0 127 Natural Gas Fired Combined Cycle ... (OP) Operating Northampton 40.6175 -75.3147
14183 56607 Calpine Bethlehem LLC 55690 Bethlehem Power Plant IPP Non-CHP PA CTG5 127.0 118 Natural Gas Fired Combined Cycle ... (OP) Operating Northampton 40.6175 -75.3147
14184 56607 Calpine Bethlehem LLC 55690 Bethlehem Power Plant IPP Non-CHP PA CTG6 127.0 127 Natural Gas Fired Combined Cycle ... (OP) Operating Northampton 40.6175 -75.3147
14185 56607 Calpine Bethlehem LLC 55690 Bethlehem Power Plant IPP Non-CHP PA CTG7 127.0 127 Natural Gas Fired Combined Cycle ... (OP) Operating Northampton 40.6175 -75.3147
14186 56607 Calpine Bethlehem LLC 55690 Bethlehem Power Plant IPP Non-CHP PA STG4 195.5 195 Natural Gas Fired Combined Cycle ... (OP) Operating Northampton 40.6175 -75.3147
14187 56607 Calpine Bethlehem LLC 55690 Bethlehem Power Plant IPP Non-CHP PA STG8 195.5 195 Natural Gas Fired Combined Cycle ... (OP) Operating Northampton 40.6175 -75.3147
14204 23279 Allegheny Energy Supply Co LLC 55710 FirstEnergy Allegheny Energy Units 3 4 & 5 IPP Non-CHP PA UNT3 184.0 167 Natural Gas Fired Combined Cycle ... (OP) Operating Allegheny 40.5453 -79.7686
14205 23279 Allegheny Energy Supply Co LLC 55710 FirstEnergy Allegheny Energy Units 3 4 & 5 IPP Non-CHP PA UNT4 184.0 167 Natural Gas Fired Combined Cycle ... (OP) Operating Allegheny 40.5453 -79.7686
14206 23279 Allegheny Energy Supply Co LLC 55710 FirstEnergy Allegheny Energy Units 3 4 & 5 IPP Non-CHP PA UNT5 188.0 175 Natural Gas Fired Combined Cycle ... (OP) Operating Allegheny 40.5453 -79.7686
14290 6693 FPL Energy Marcus Hook LP 55801 FPL Energy Marcus Hook LP IPP CHP PA CT13 188.2 172 Natural Gas Fired Combined Cycle ... (OP) Operating Delaware 39.807 -75.4216
14291 6693 FPL Energy Marcus Hook LP 55801 FPL Energy Marcus Hook LP IPP CHP PA CT1A 188.2 178.7 Natural Gas Fired Combined Cycle ... (OP) Operating Delaware 39.807 -75.4216
14292 6693 FPL Energy Marcus Hook LP 55801 FPL Energy Marcus Hook LP IPP CHP PA CTIB 188.2 172 Natural Gas Fired Combined Cycle ... (OP) Operating Delaware 39.807 -75.4216
14293 6693 FPL Energy Marcus Hook LP 55801 FPL Energy Marcus Hook LP IPP CHP PA STG 271.5 263 Natural Gas Fired Combined Cycle ... (OP) Operating Delaware 39.807 -75.4216
14433 54885 NRG Wholesale Generation LP 55976 Hunterstown Power Plant IPP Non-CHP PA 101 179.0 153 Natural Gas Fired Combined Cycle ... (OP) Operating Adams 39.8725 -77.1672
14434 54885 NRG Wholesale Generation LP 55976 Hunterstown Power Plant IPP Non-CHP PA 201 179.0 153 Natural Gas Fired Combined Cycle ... (OP) Operating Adams 39.8725 -77.1672
14435 54885 NRG Wholesale Generation LP 55976 Hunterstown Power Plant IPP Non-CHP PA 301 179.0 153 Natural Gas Fired Combined Cycle ... (OP) Operating Adams 39.8725 -77.1672
14436 54885 NRG Wholesale Generation LP 55976 Hunterstown Power Plant IPP Non-CHP PA 401 361.0 299 Natural Gas Fired Combined Cycle ... (OP) Operating Adams 39.8725 -77.1672

61 rows × 26 columns

Repeat groupby


In [50]:
cols = ['Plant ID', 'Nameplate Capacity (MW)']
facility_cap = capacity.loc[:,cols].groupby('Plant ID').sum()
facility_cap.head()


Out[50]:
Nameplate Capacity (MW)
Plant ID
2 53.9
3 2569.5
4 225.0
7 138.0
8 1166.7

Load generation data


In [51]:
generation = pd.read_excel(fn3, header=5)

In [52]:
generation.head()


Out[52]:
Plant Id Combined Heat And Power Plant Nuclear Unit Id Plant Name Operator Name Operator Id Plant State Census Region NERC Region Reserved ... Netgen September Netgen October Netgen November Netgen December Total Fuel Consumption Quantity Electric Fuel Consumption Quantity Total Fuel Consumption MMBtu Elec Fuel Consumption MMBtu Net Generation (Megawatthours) YEAR
0 3 N NaN Barry Alabama Power Co 195 AL ESC SERC NaN ... 251839 219263 . . 4782719 4782719 4877614 4877614 2386339.000 2016
1 3 N NaN Barry Alabama Power Co 195 AL ESC SERC NaN ... 463646 401506 . . 42413079 42413079 43208127 43208127 4486082.000 2016
2 3 N NaN Barry Alabama Power Co 195 AL ESC SERC NaN ... 473794 286736 . . 1773704 1773704 37426485 37426485 3706973.300 2016
3 3 N NaN Barry Alabama Power Co 195 AL ESC SERC NaN ... 11246.3 14387.7 . . 857741 857741 874585 874585 86059.704 2016
4 4 N NaN Walter Bouldin Dam Alabama Power Co 195 AL ESC SERC NaN ... 3380 884 . . 0 0 4239930 4239930 454977.000 2016

5 rows × 97 columns


In [53]:
generation.dtypes


Out[53]:
Plant Id                                 int64
Combined Heat And\nPower Plant          object
Nuclear Unit Id                        float64
Plant Name                              object
Operator Name                           object
Operator Id                              int64
Plant State                             object
Census Region                           object
NERC Region                             object
Reserved                               float64
NAICS Code                               int64
EIA Sector Number                        int64
Sector Name                             object
Reported\nPrime Mover                   object
Reported\nFuel Type Code                object
AER\nFuel Type Code                     object
Reserved.1                             float64
Reserved.2                             float64
Physical\nUnit Label                    object
Quantity\nJanuary                       object
Quantity\nFebruary                      object
Quantity\nMarch                         object
Quantity\nApril                         object
Quantity\nMay                           object
Quantity\nJune                          object
Quantity\nJuly                          object
Quantity\nAugust                        object
Quantity\nSeptember                     object
Quantity\nOctober                       object
Quantity\nNovember                      object
                                        ...   
Elec_MMBtu\nJanuary                     object
Elec_MMBtu\nFebruary                    object
Elec_MMBtu\nMarch                       object
Elec_MMBtu\nApril                       object
Elec_MMBtu\nMay                         object
Elec_MMBtu\nJune                        object
Elec_MMBtu\nJuly                        object
Elec_MMBtu\nAugust                      object
Elec_MMBtu\nSeptember                   object
Elec_MMBtu\nOctober                     object
Elec_MMBtu\nNovember                    object
Elec_MMBtu\nDecember                    object
Netgen\nJanuary                         object
Netgen\nFebruary                        object
Netgen\nMarch                           object
Netgen\nApril                           object
Netgen\nMay                             object
Netgen\nJune                            object
Netgen\nJuly                            object
Netgen\nAugust                          object
Netgen\nSeptember                       object
Netgen\nOctober                         object
Netgen\nNovember                        object
Netgen\nDecember                        object
Total Fuel Consumption\nQuantity         int64
Electric Fuel Consumption\nQuantity      int64
Total Fuel Consumption\nMMBtu            int64
Elec Fuel Consumption\nMMBtu             int64
Net Generation\n(Megawatthours)        float64
YEAR                                     int64
dtype: object

In [54]:
generation.tail()


Out[54]:
Plant Id Combined Heat And Power Plant Nuclear Unit Id Plant Name Operator Name Operator Id Plant State Census Region NERC Region Reserved ... Netgen September Netgen October Netgen November Netgen December Total Fuel Consumption Quantity Electric Fuel Consumption Quantity Total Fuel Consumption MMBtu Elec Fuel Consumption MMBtu Net Generation (Megawatthours) YEAR
6841 99999 Y NaN State-Fuel Level Increment State-Fuel Level Increment 99999 WY MTN NaN NaN ... 20.03 20.073 . . 2471 197 14391 1144 225.055 2016
6842 99999 Y NaN State-Fuel Level Increment State-Fuel Level Increment 99999 WY MTN NaN NaN ... 8371.86 6890.44 . . 5750996 817170 5662749 804426 84996.866 2016
6843 99999 Y NaN State-Fuel Level Increment State-Fuel Level Increment 99999 WY MTN NaN NaN ... 282.565 112.177 . . 7449697 152028 1362700 27810 3212.683 2016
6844 99999 Y NaN State-Fuel Level Increment State-Fuel Level Increment 99999 WY MTN NaN NaN ... 0 0 . . 0 0 0 0 0.000 2016
6845 99999 Y NaN State-Fuel Level Increment State-Fuel Level Increment 99999 WY MTN NaN NaN ... 10293 7668.97 . . 406340 92966 7110741 1626327 133198.240 2016

5 rows × 97 columns


In [55]:
generation.replace('.', 0, inplace=True)

In [56]:
generation.dtypes


Out[56]:
Plant Id                                 int64
Combined Heat And\nPower Plant          object
Nuclear Unit Id                        float64
Plant Name                              object
Operator Name                           object
Operator Id                              int64
Plant State                             object
Census Region                           object
NERC Region                             object
Reserved                               float64
NAICS Code                               int64
EIA Sector Number                        int64
Sector Name                             object
Reported\nPrime Mover                   object
Reported\nFuel Type Code                object
AER\nFuel Type Code                     object
Reserved.1                             float64
Reserved.2                             float64
Physical\nUnit Label                    object
Quantity\nJanuary                        int64
Quantity\nFebruary                       int64
Quantity\nMarch                          int64
Quantity\nApril                          int64
Quantity\nMay                            int64
Quantity\nJune                           int64
Quantity\nJuly                           int64
Quantity\nAugust                         int64
Quantity\nSeptember                      int64
Quantity\nOctober                        int64
Quantity\nNovember                       int64
                                        ...   
Elec_MMBtu\nJanuary                      int64
Elec_MMBtu\nFebruary                     int64
Elec_MMBtu\nMarch                        int64
Elec_MMBtu\nApril                        int64
Elec_MMBtu\nMay                          int64
Elec_MMBtu\nJune                         int64
Elec_MMBtu\nJuly                         int64
Elec_MMBtu\nAugust                       int64
Elec_MMBtu\nSeptember                    int64
Elec_MMBtu\nOctober                      int64
Elec_MMBtu\nNovember                     int64
Elec_MMBtu\nDecember                     int64
Netgen\nJanuary                        float64
Netgen\nFebruary                       float64
Netgen\nMarch                          float64
Netgen\nApril                          float64
Netgen\nMay                            float64
Netgen\nJune                           float64
Netgen\nJuly                           float64
Netgen\nAugust                         float64
Netgen\nSeptember                      float64
Netgen\nOctober                        float64
Netgen\nNovember                         int64
Netgen\nDecember                         int64
Total Fuel Consumption\nQuantity         int64
Electric Fuel Consumption\nQuantity      int64
Total Fuel Consumption\nMMBtu            int64
Elec Fuel Consumption\nMMBtu             int64
Net Generation\n(Megawatthours)        float64
YEAR                                     int64
dtype: object

In [57]:
generation.columns


Out[57]:
Index([u'Plant Id', u'Combined Heat And\nPower Plant', u'Nuclear Unit Id',
       u'Plant Name', u'Operator Name', u'Operator Id', u'Plant State',
       u'Census Region', u'NERC Region', u'Reserved', u'NAICS Code',
       u'EIA Sector Number', u'Sector Name', u'Reported\nPrime Mover',
       u'Reported\nFuel Type Code', u'AER\nFuel Type Code', u'Reserved.1',
       u'Reserved.2', u'Physical\nUnit Label', u'Quantity\nJanuary',
       u'Quantity\nFebruary', u'Quantity\nMarch', u'Quantity\nApril',
       u'Quantity\nMay', u'Quantity\nJune', u'Quantity\nJuly',
       u'Quantity\nAugust', u'Quantity\nSeptember', u'Quantity\nOctober',
       u'Quantity\nNovember', u'Quantity\nDecember', u'Elec_Quantity\nJanuary',
       u'Elec_Quantity\nFebruary', u'Elec_Quantity\nMarch',
       u'Elec_Quantity\nApril', u'Elec_Quantity\nMay', u'Elec_Quantity\nJune',
       u'Elec_Quantity\nJuly', u'Elec_Quantity\nAugust',
       u'Elec_Quantity\nSeptember', u'Elec_Quantity\nOctober',
       u'Elec_Quantity\nNovember', u'Elec_Quantity\nDecember',
       u'MMBtuPer_Unit\nJanuary', u'MMBtuPer_Unit\nFebruary',
       u'MMBtuPer_Unit\nMarch', u'MMBtuPer_Unit\nApril', u'MMBtuPer_Unit\nMay',
       u'MMBtuPer_Unit\nJune', u'MMBtuPer_Unit\nJuly',
       u'MMBtuPer_Unit\nAugust', u'MMBtuPer_Unit\nSeptember',
       u'MMBtuPer_Unit\nOctober', u'MMBtuPer_Unit\nNovember',
       u'MMBtuPer_Unit\nDecember', u'Tot_MMBtu\nJanuary',
       u'Tot_MMBtu\nFebruary', u'Tot_MMBtu\nMarch', u'Tot_MMBtu\nApril',
       u'Tot_MMBtu\nMay', u'Tot_MMBtu\nJune', u'Tot_MMBtu\nJuly',
       u'Tot_MMBtu\nAugust', u'Tot_MMBtu\nSeptember', u'Tot_MMBtu\nOctober',
       u'Tot_MMBtu\nNovember', u'Tot_MMBtu\nDecember', u'Elec_MMBtu\nJanuary',
       u'Elec_MMBtu\nFebruary', u'Elec_MMBtu\nMarch', u'Elec_MMBtu\nApril',
       u'Elec_MMBtu\nMay', u'Elec_MMBtu\nJune', u'Elec_MMBtu\nJuly',
       u'Elec_MMBtu\nAugust', u'Elec_MMBtu\nSeptember', u'Elec_MMBtu\nOctober',
       u'Elec_MMBtu\nNovember', u'Elec_MMBtu\nDecember', u'Netgen\nJanuary',
       u'Netgen\nFebruary', u'Netgen\nMarch', u'Netgen\nApril', u'Netgen\nMay',
       u'Netgen\nJune', u'Netgen\nJuly', u'Netgen\nAugust',
       u'Netgen\nSeptember', u'Netgen\nOctober', u'Netgen\nNovember',
       u'Netgen\nDecember', u'Total Fuel Consumption\nQuantity',
       u'Electric Fuel Consumption\nQuantity',
       u'Total Fuel Consumption\nMMBtu', u'Elec Fuel Consumption\nMMBtu',
       u'Net Generation\n(Megawatthours)', u'YEAR'],
      dtype='object')

In [58]:
generation.columns = [name.strip().replace('\n', ' ') for name in generation.columns]
generation.columns


Out[58]:
Index([u'Plant Id', u'Combined Heat And Power Plant', u'Nuclear Unit Id',
       u'Plant Name', u'Operator Name', u'Operator Id', u'Plant State',
       u'Census Region', u'NERC Region', u'Reserved', u'NAICS Code',
       u'EIA Sector Number', u'Sector Name', u'Reported Prime Mover',
       u'Reported Fuel Type Code', u'AER Fuel Type Code', u'Reserved.1',
       u'Reserved.2', u'Physical Unit Label', u'Quantity January',
       u'Quantity February', u'Quantity March', u'Quantity April',
       u'Quantity May', u'Quantity June', u'Quantity July', u'Quantity August',
       u'Quantity September', u'Quantity October', u'Quantity November',
       u'Quantity December', u'Elec_Quantity January',
       u'Elec_Quantity February', u'Elec_Quantity March',
       u'Elec_Quantity April', u'Elec_Quantity May', u'Elec_Quantity June',
       u'Elec_Quantity July', u'Elec_Quantity August',
       u'Elec_Quantity September', u'Elec_Quantity October',
       u'Elec_Quantity November', u'Elec_Quantity December',
       u'MMBtuPer_Unit January', u'MMBtuPer_Unit February',
       u'MMBtuPer_Unit March', u'MMBtuPer_Unit April', u'MMBtuPer_Unit May',
       u'MMBtuPer_Unit June', u'MMBtuPer_Unit July', u'MMBtuPer_Unit August',
       u'MMBtuPer_Unit September', u'MMBtuPer_Unit October',
       u'MMBtuPer_Unit November', u'MMBtuPer_Unit December',
       u'Tot_MMBtu January', u'Tot_MMBtu February', u'Tot_MMBtu March',
       u'Tot_MMBtu April', u'Tot_MMBtu May', u'Tot_MMBtu June',
       u'Tot_MMBtu July', u'Tot_MMBtu August', u'Tot_MMBtu September',
       u'Tot_MMBtu October', u'Tot_MMBtu November', u'Tot_MMBtu December',
       u'Elec_MMBtu January', u'Elec_MMBtu February', u'Elec_MMBtu March',
       u'Elec_MMBtu April', u'Elec_MMBtu May', u'Elec_MMBtu June',
       u'Elec_MMBtu July', u'Elec_MMBtu August', u'Elec_MMBtu September',
       u'Elec_MMBtu October', u'Elec_MMBtu November', u'Elec_MMBtu December',
       u'Netgen January', u'Netgen February', u'Netgen March', u'Netgen April',
       u'Netgen May', u'Netgen June', u'Netgen July', u'Netgen August',
       u'Netgen September', u'Netgen October', u'Netgen November',
       u'Netgen December', u'Total Fuel Consumption Quantity',
       u'Electric Fuel Consumption Quantity', u'Total Fuel Consumption MMBtu',
       u'Elec Fuel Consumption MMBtu', u'Net Generation (Megawatthours)',
       u'YEAR'],
      dtype='object')

In [59]:
'Quantity January'.split()


Out[59]:
['Quantity', 'January']

In [60]:
id_cols = ['Plant Id', 'NERC Region', 'AER Fuel Type Code']
monthly_cols = []

def find_col_names(cols):
    for col in cols:
        if 'January' in col:
            monthly_cols.append(col.split()[0])

find_col_names(generation.columns)
id_cols + monthly_cols


Out[60]:
['Plant Id',
 'NERC Region',
 'AER Fuel Type Code',
 u'Quantity',
 u'Elec_Quantity',
 u'MMBtuPer_Unit',
 u'Tot_MMBtu',
 u'Elec_MMBtu',
 u'Netgen']

In [61]:
gen_may = pd.DataFrame(columns=id_cols + monthly_cols)
gen_may


Out[61]:
Plant Id NERC Region AER Fuel Type Code Quantity Elec_Quantity MMBtuPer_Unit Tot_MMBtu Elec_MMBtu Netgen

In [62]:
gen_may[id_cols] = generation.loc[:,id_cols]
gen_may.head()


Out[62]:
Plant Id NERC Region AER Fuel Type Code Quantity Elec_Quantity MMBtuPer_Unit Tot_MMBtu Elec_MMBtu Netgen
0 3 SERC NG NaN NaN NaN NaN NaN NaN
1 3 SERC NG NaN NaN NaN NaN NaN NaN
2 3 SERC COL NaN NaN NaN NaN NaN NaN
3 3 SERC NG NaN NaN NaN NaN NaN NaN
4 4 SERC HYC NaN NaN NaN NaN NaN NaN

In [63]:
for col in monthly_cols:
    gen_may[col] = generation.loc[:,col + ' May']

In [64]:
gen_may.head()


Out[64]:
Plant Id NERC Region AER Fuel Type Code Quantity Elec_Quantity MMBtuPer_Unit Tot_MMBtu Elec_MMBtu Netgen
0 3 SERC NG 64489 64489 1.017 65585 65585 223662.00
1 3 SERC NG 4355654 4355654 1.017 4429700 4429700 421779.00
2 3 SERC COL 178956 178956 21.425 3834132 3834132 376726.94
3 3 SERC NG 63097 63097 1.017 64170 64170 6305.06
4 4 SERC HYC 0 0 0.000 95361 95361 10233.00

Groupby facilities


In [65]:
facility_gen = gen_may.groupby(['Plant Id', 'NERC Region']).sum()
facility_gen.head()


Out[65]:
Quantity Elec_Quantity MMBtuPer_Unit Tot_MMBtu Elec_MMBtu Netgen
Plant Id NERC Region
3 SERC 4662196 4662196 24.476 8393587 8393587 1028473.000
4 SERC 0 0 0.000 95361 95361 10233.000
8 SERC 188233 188233 30.364 4588547 4588547 471836.004
10 SERC 116191 116191 2.066 120025 120025 6734.000
14 SERC 0 0 0.000 132060 132060 14171.000

In [66]:
facility_gen.reset_index('NERC Region', inplace=True)
facility_gen.head()


Out[66]:
NERC Region Quantity Elec_Quantity MMBtuPer_Unit Tot_MMBtu Elec_MMBtu Netgen
Plant Id
3 SERC 4662196 4662196 24.476 8393587 8393587 1028473.000
4 SERC 0 0 0.000 95361 95361 10233.000
8 SERC 188233 188233 30.364 4588547 4588547 471836.004
10 SERC 116191 116191 2.066 120025 120025 6734.000
14 SERC 0 0 0.000 132060 132060 14171.000

Merge data from all three sources


In [67]:
merged = facility_gen.merge(facility_cap, how='inner',
                           left_index=True, right_index=True)

In [68]:
merged.head()


Out[68]:
NERC Region Quantity Elec_Quantity MMBtuPer_Unit Tot_MMBtu Elec_MMBtu Netgen Nameplate Capacity (MW)
3 SERC 4662196 4662196 24.476 8393587 8393587 1028473.000 2569.5
4 SERC 0 0 0.000 95361 95361 10233.000 225.0
8 SERC 188233 188233 30.364 4588547 4588547 471836.004 1166.7
10 SERC 116191 116191 2.066 120025 120025 6734.000 1288.4
14 SERC 0 0 0.000 132060 132060 14171.000 128.1

In [69]:
final = merged.merge(facility_emiss, how='outer', 
                     left_index=True, right_index=True)

In [70]:
final


Out[70]:
NERC Region Quantity Elec_Quantity MMBtuPer_Unit Tot_MMBtu Elec_MMBtu Netgen Nameplate Capacity (MW) Operating Time Gross Load (MW-h) Steam Load (1000lb) SO2 (tons) Avg. NOx Rate (lb/MMBtu) NOx (tons) CO2 (short tons) Heat Input (MMBtu) EPA Region
3 SERC 4662196.0 4662196.0 24.476 8393587.0 8393587.0 1028473.000 2569.5 3844.00 1048450.25 NaN 595.911 0.5760 411.165 677078.976 8471790.125 4.0
4 SERC 0.0 0.0 0.000 95361.0 95361.0 10233.000 225.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
7 NaN NaN NaN NaN NaN NaN NaN NaN 924.00 NaN 222159.75 0.990 0.2067 13.814 15771.300 266053.425 4.0
8 SERC 188233.0 188233.0 30.364 4588547.0 4588547.0 471836.004 1166.7 1837.25 505777.25 NaN 125.662 0.5375 440.348 531418.603 5179513.525 4.0
9 NaN NaN NaN NaN NaN NaN NaN NaN 20.60 541.68 NaN 0.003 0.2751 1.504 NaN 10441.833 6.0
10 SERC 116191.0 116191.0 2.066 120025.0 120025.0 6734.000 1288.4 188.25 8897.75 NaN 48.579 0.8474 10.162 11340.124 144258.150 4.0
14 SERC 0.0 0.0 0.000 132060.0 132060.0 14171.000 128.1 NaN NaN NaN NaN NaN NaN NaN NaN NaN
15 SERC 0.0 0.0 0.000 219444.0 219444.0 23548.000 177.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
16 SERC 0.0 0.0 0.000 145265.0 145265.0 15588.000 210.6 NaN NaN NaN NaN NaN NaN NaN NaN NaN
17 SERC 0.0 0.0 0.000 193742.0 193742.0 20790.000 170.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
18 SERC 0.0 0.0 0.000 54386.0 54386.0 5836.000 181.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
26 SERC 197510.0 197510.0 30.196 4577634.0 4577634.0 453833.000 2034.0 744.00 495791.00 NaN 173.698 0.0646 165.370 524604.900 5113099.400 4.0
46 SERC 0.0 0.0 0.000 25805554.0 25805554.0 2467542.000 3494.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
47 SERC 58.0 58.0 5.800 336.0 336.0 62.000 1026.0 20.00 177.00 NaN 0.333 4.4379 0.722 192.400 2765.600 4.0
48 SERC 0.0 0.0 0.000 177946.0 177946.0 19095.000 115.2 NaN NaN NaN NaN NaN NaN NaN NaN NaN
49 SERC 0.0 0.0 0.000 261286.0 261286.0 28038.000 404.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
50 SERC 0.0 0.0 0.000 0.0 0.0 0.000 575.0 0.00 NaN NaN NaN NaN NaN NaN NaN 4.0
51 SPP 241664.0 241664.0 14.902 2799148.0 2799148.0 238020.998 720.7 553.48 262392.63 NaN 1081.656 0.2080 241.863 270128.775 2481213.560 6.0
54 SERC 177832.0 177832.0 1.066 189569.0 189569.0 15037.000 1055.0 254.45 15652.65 NaN 0.057 0.3753 2.787 11101.898 186799.693 4.0
56 SERC 49159.0 49159.0 28.560 1098557.0 1098557.0 97056.000 538.0 759.23 112793.47 NaN 63.902 0.5125 167.878 129301.129 1260257.488 4.0
59 NaN NaN NaN NaN NaN NaN NaN NaN 321.07 18822.00 NaN 16.264 0.2297 24.957 21946.742 209245.816 7.0
60 MRO 24713.0 24713.0 22.206 404792.0 404792.0 31448.000 324.3 753.95 36111.00 NaN 176.503 0.2169 39.165 44877.292 427905.242 7.0
64 ASCC 102.0 102.0 5.712 583.0 583.0 21.000 61.7 NaN NaN NaN NaN NaN NaN NaN NaN NaN
77 ASCC 0.0 0.0 0.000 84617.0 84617.0 9080.000 44.4 NaN NaN NaN NaN NaN NaN NaN NaN NaN
78 ASCC 0.0 0.0 0.000 157007.0 157007.0 16848.000 78.2 NaN NaN NaN NaN NaN NaN NaN NaN NaN
87 WECC 52499.0 52499.0 19.578 867759.0 867759.0 74925.000 257.0 744.00 82439.00 NaN 34.069 0.3811 161.168 88806.200 846735.000 6.0
96 ASCC 76562.0 76562.0 1.000 76562.0 76562.0 3455.000 312.4 NaN NaN NaN NaN NaN NaN NaN NaN NaN
104 WECC 106.0 106.0 0.000 0.0 0.0 44845.000 199.8 NaN NaN NaN NaN NaN NaN NaN NaN NaN
108 SPP 102821.0 102821.0 18.837 1607158.0 1607158.0 146461.005 348.7 660.18 160882.24 NaN 95.013 0.1813 151.412 173507.748 1654354.527 7.0
113 WECC 68608.0 68608.0 24.756 1253737.0 1253737.0 103305.000 839.9 992.93 120001.76 NaN 57.635 0.6462 149.985 135364.206 1319344.965 9.0
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
59654 TRE 0.0 0.0 0.000 243748.0 243748.0 26156.000 78.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
59655 MRO 0.0 0.0 0.000 313100.0 313100.0 33598.000 97.8 NaN NaN NaN NaN NaN NaN NaN NaN NaN
59702 WECC 0.0 0.0 0.000 141779.0 141779.0 15214.000 50.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
59723 WECC 0.0 0.0 0.000 141024.0 141024.0 15133.000 30.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
59732 TRE 0.0 0.0 0.000 408918.0 408918.0 43880.000 150.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
59733 TRE 0.0 0.0 0.000 392479.0 392479.0 42116.000 150.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
59734 TRE 0.0 0.0 0.000 405451.0 405451.0 43508.000 150.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
59778 SERC 0.0 0.0 0.000 65186.0 65186.0 6995.000 47.7 NaN NaN NaN NaN NaN NaN NaN NaN NaN
59784 WECC 1339613.0 1339613.0 1.024 1371764.0 1371764.0 187059.000 619.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
59837 SPP 0.0 0.0 0.000 465577.0 465577.0 49960.000 150.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
59838 SPP 0.0 0.0 0.000 181338.0 181338.0 19459.000 50.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
59862 SERC 0.0 0.0 0.000 58831.0 58831.0 6313.000 30.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
59894 SERC 0.0 0.0 0.000 66202.0 66202.0 7104.000 30.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
59926 NaN NaN NaN NaN NaN NaN NaN NaN 24.63 2794.92 NaN 0.015 0.0320 0.806 2972.500 50368.700 5.0
59943 TRE 0.0 0.0 0.000 757169.0 757169.0 81250.000 207.2 NaN NaN NaN NaN NaN NaN NaN NaN NaN
59944 SERC 0.0 0.0 0.000 144920.0 144920.0 15551.000 80.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
59965 WECC 0.0 0.0 0.000 89956.0 89956.0 9653.000 62.1 NaN NaN NaN NaN NaN NaN NaN NaN NaN
59974 WECC 0.0 0.0 0.000 690044.0 690044.0 74047.000 250.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
59975 WECC 0.0 0.0 0.000 317582.0 317582.0 34079.000 150.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
60008 WECC 0.0 0.0 0.000 127866.0 127866.0 13721.000 52.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
60013 SPP 0.0 0.0 0.000 410055.0 410055.0 44002.000 151.8 NaN NaN NaN NaN NaN NaN NaN NaN NaN
60049 WECC 0.0 0.0 0.000 306101.0 306101.0 32847.000 80.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
60059 TRE 0.0 0.0 0.000 295142.0 295142.0 31671.000 110.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
60069 SPP 0.0 0.0 0.000 612939.0 612939.0 65773.000 198.6 NaN NaN NaN NaN NaN NaN NaN NaN NaN
60093 WECC 0.0 0.0 0.000 263569.0 263569.0 28283.000 109.8 NaN NaN NaN NaN NaN NaN NaN NaN NaN
60104 TRE 0.0 0.0 0.000 796420.0 796420.0 85462.000 249.7 NaN NaN NaN NaN NaN NaN NaN NaN NaN
60262 SPP 0.0 0.0 0.000 240132.0 240132.0 25768.000 73.4 NaN NaN NaN NaN NaN NaN NaN NaN NaN
60314 SPP 0.0 0.0 0.000 103935.0 103935.0 11153.000 35.8 NaN NaN NaN NaN NaN NaN NaN NaN NaN
60419 WECC 0.0 0.0 0.000 142450.0 142450.0 15286.000 25.0 NaN NaN NaN NaN NaN NaN NaN NaN NaN
70454 NaN NaN NaN NaN NaN NaN NaN NaN 62.78 7178.74 NaN 0.026 0.1711 3.388 5164.599 86899.023 4.0

2510 rows × 17 columns


In [71]:
final.to_csv('Final data.csv')

In [ ]:


In [75]:
final.plot.scatter(x='Nameplate Capacity (MW)',
                   y='Netgen')


Out[75]:
<matplotlib.axes._subplots.AxesSubplot at 0x11d524ed0>

In [76]:
import seaborn as sns

In [79]:
final.plot.scatter(x='Nameplate Capacity (MW)',
                       y='Netgen')


Out[79]:
<matplotlib.axes._subplots.AxesSubplot at 0x11d382290>

In [ ]: