In this analysis, I was tasked to calculate the growth rate of different energy production methods in the United States, and find the two fastest growing renewable energy methods.
1. 12/21/2020 Energy_DS - Jupyter Notebook
localhost:8888/notebooks/%231 REMCO/Energy_DS.ipynb 1/9
Energy Production Analysis in the USA
In this notebook we will be analyzing growth rates of energy production
in the US. We will most likely want to compare Total Fossil Fuel
Production with the Total Renewable Energy Production, to understand
how the production as increased or decreased over the years.
Additionally, we will calculate growth rate for both.
Data is from 1949-2019. Note: Solar Energy Production started 1984
In [1]:
In [2]:
In [3]:
Out[3]:
Annual
Total
Coal
Production
Natural
Gas (Dry)
Production
Crude Oil
Production
Natural
Gas Plant
Liquids
Production
Total
Fossil
Fuels
Production
Nuclear
Electric
Power
Production
Hydroelectric
Power
Production
G
P
0 1949 11.973882 5.377243 10.683252 0.706102 28.740479 0.0 1.424722
1 1950 14.060135 6.232975 11.446729 0.813366 32.553205 0.0 1.415411
2 1951 14.419325 7.415733 13.036724 0.910336 35.782118 0.0 1.423795
3 1952 12.734313 7.963599 13.281049 0.985701 34.964662 0.0 1.465812
4 1953 12.277746 8.338838 13.671076 1.050702 35.338361 0.0 1.412859
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.pyplot import figure
xls = pd.ExcelFile('Energy_Production_by_Source.xlsx')
df1 = pd.read_excel(xls, 'Annual Data')
df2 = pd.read_excel(xls, 'Monthly Data')
df1.head()
3. 12/21/2020 Energy_DS - Jupyter Notebook
localhost:8888/notebooks/%231 REMCO/Energy_DS.ipynb 3/9
In [6]:
Graph Total Renewable Energy Production 1984 - 2019
In [7]:
Graph Solar Energy Production Production since 1984 - 2019
Out[6]: [<matplotlib.lines.Line2D at 0x7f96fb59fe50>]
Out[7]: [<matplotlib.lines.Line2D at 0x7f96fb7ee1d0>]
fossil_fuels = df1['Total Fossil Fuels Production']
fossil_fuels = fossil_fuels[35:]
#figure(figsize=(50,5))
plt.plot(fossil_fuels)
#plt.xticks(range(70), range(1949, 2019, 1))
renewable_energy = df1['Total Renewable Energy Production']
renewable_energy = renewable_energy[35:]
plt.plot(renewable_energy)
4. 12/21/2020 Energy_DS - Jupyter Notebook
localhost:8888/notebooks/%231 REMCO/Energy_DS.ipynb 4/9
In [8]:
Modular Code - Calculate Growth Rate
In [9]:
Out[8]: [<matplotlib.lines.Line2D at 0x7f96fb8d3290>]
0.777084 0.570368
#1984, starts 1949
solar_energy = df1['Solar Energy Production']
#print(1949-1984)
solar_energy = solar_energy[35:]
plt.plot(solar_energy)
def get_energyproduction_number(year_selected, sector):
'''
Function that inputs year selected, and energy sector from energy produ
Outputs the energy produced (which is in quadrillion BTU) in exact year
'''
year = df1[df1['Annual Total'] == year_selected]
new_sector = year[sector]
new_sector = new_sector.iloc[0]
return new_sector
x = get_energyproduction_number(2017, 'Solar Energy Production')
y = get_energyproduction_number(2016, 'Solar Energy Production')
print(x,y)
5. 12/21/2020 Energy_DS - Jupyter Notebook
localhost:8888/notebooks/%231 REMCO/Energy_DS.ipynb 5/9
In [10]:
In [11]:
In [12]:
Out[10]: 2.0559089782613755
Out[12]: [<matplotlib.lines.Line2D at 0x7f96fb9b5510>]
def get_growth_rate(year1, year2, sector):
"""
Function that inputs two exacts energy production years
Function outputs the calculation of growth rate from one year to anothe
"""
year1_energy_produced = get_energyproduction_number(year1, sector)
year2_energy_produced = get_energyproduction_number(year2, sector)
growth_rate = (year2_energy_produced - year1_energy_produced)/year1_ene
return growth_rate
get_growth_rate(2000, 2001, 'Total Fossil Fuels Production')
def get_yearly_sector_growth(year1, year2, sector):
"""
Function that inputs sector
Outputs growth rate since inception date
"""
lst = []
while year1 < 2019:
x = get_growth_rate(year1, year2, sector)
lst.append(x)
year1 += 1
year2 += 1
return lst
list = get_yearly_sector_growth(2000, 2001, 'Total Renewable Energy Product
plt.plot(list)
6. 12/21/2020 Energy_DS - Jupyter Notebook
localhost:8888/notebooks/%231 REMCO/Energy_DS.ipynb 6/9
In [13]:
In [14]:
Out[13]: [-15.403905195088488,
11.02586476117117,
3.6916527276159896,
2.0227962561676858,
2.6084377661265084,
5.874329589127594,
-1.1520376639610785,
10.462989260052472,
6.026325911007182,
9.033916630338478,
11.857279532418646,
-4.446775262625664,
5.985639461905219,
3.7016095833647844,
-0.386545172654705,
7.134584913912513,
7.4168712807755925,
2.790667638568073,
0.002033303778008388]
get_yearly_sector_growth(2000, 2001, 'Total Renewable Energy Production')
def get_yearly_sector_growth(year1, year2, sector):
"""
Function that inputs sector
Outputs growth rate since inception date
"""
lst = []
while year1 < 2018:
x = get_growth_rate(year1, year2, sector)
lst.append(x)
year1 += 1
year2 += 1
return lst
7. 12/21/2020 Energy_DS - Jupyter Notebook
localhost:8888/notebooks/%231 REMCO/Energy_DS.ipynb 7/9
In [15]:
In [16]:
Out[15]: ([<matplotlib.axis.XTick at 0x7f96fb9e6e90>,
<matplotlib.axis.XTick at 0x7f96fb9e08d0>,
<matplotlib.axis.XTick at 0x7f96fb8feed0>,
<matplotlib.axis.XTick at 0x7f96fba29f90>,
<matplotlib.axis.XTick at 0x7f96fba9c410>,
<matplotlib.axis.XTick at 0x7f96fba9c210>,
<matplotlib.axis.XTick at 0x7f96fba9cd10>,
<matplotlib.axis.XTick at 0x7f96fbaa3390>,
<matplotlib.axis.XTick at 0x7f96fbaa3290>,
<matplotlib.axis.XTick at 0x7f96fbaaa350>,
<matplotlib.axis.XTick at 0x7f96fbaaa650>,
<matplotlib.axis.XTick at 0x7f96fbaaa510>,
<matplotlib.axis.XTick at 0x7f96fbab0310>,
<matplotlib.axis.XTick at 0x7f96fbab0210>,
<matplotlib.axis.XTick at 0x7f96fbab0e10>,
<matplotlib.axis.XTick at 0x7f96fbab0910>,
<matplotlib.axis.XTick at 0x7f96fbaa3990>,
<matplotlib.axis.XTick at 0x7f96fbab8510>],
<a list of 18 Text xticklabel objects>)
total_fossil_fuel_growthrate_year = get_yearly_sector_growth(2000, 2001, 'T
plt.plot(total_fossil_fuel_growthrate_year)
plt.xticks(range(0,18), range(2000,2018,1))
def get_average_growth(year1, year2, sector):
"""
Function that inputs a list of numbers, which are the growth rate of ea
Performs a calculation by summing all growth rates, and then divides th
Function outputs a number which is the avg growth rate.
"""
list_growth_rate = get_yearly_sector_growth(year1, year2, sector)
total_sum = sum(list_growth_rate)
avg_growth = total_sum/len(list_growth_rate)
return avg_growth
8. 12/21/2020 Energy_DS - Jupyter Notebook
localhost:8888/notebooks/%231 REMCO/Energy_DS.ipynb 8/9
In [17]:
In [18]:
In [19]:
In [20]:
In [21]:
In [22]:
In [23]:
In [24]:
In [25]:
In [26]:
Conclusion
Clearly, the average growth rate for Total Renewable Energy Production
has been twice the growth rate for Total Fossil Fuels Production from
1984-2019.
Additionally, in the last 20 years, Wind and Solar Energy Production have
been growing the fastest compared to other renewable energies.
Out[17]: 0.8007875658304962
Out[18]: 1.9340090984949878
Out[19]: 17.185792354542038
Out[20]: 0.2935477524487831
Out[21]: 1.3549097265165744
Out[22]: 24.245650340873755
Out[23]: 3.293788801373669
Out[24]: 3.7267783908048235
Out[25]: 4.787257846711986
Out[26]: 2.7995326374860046
get_average_growth(1984, 1985, 'Total Fossil Fuels Production')
get_average_growth(1984, 1985, 'Total Renewable Energy Production')
get_average_growth(2000, 2001, 'Solar Energy Production')
get_average_growth(2000, 2001, 'Hydroelectric Power Production')
get_average_growth(2000, 2001, 'Geothermal Energy Production')
get_average_growth(2000, 2001, 'Wind Energy Production')
get_average_growth(2000, 2001, 'Biomass Energy Production')
get_average_growth(2000, 2001, 'Crude Oil Production')
get_average_growth(2000, 2001, 'Natural Gas Plant Liquids Production')
get_average_growth(2000, 2001, 'Natural Gas (Dry) Production')