Energy Consumption
Apply time series analysis techniques to forecast energy consumption.
We'll cover the following...
Context
We'll now analyze energy consumption data from an electric utility from the United States called American Electric Power (AEP). They are present in eleven states and deliver electricity to more than five million customers.
Press + to interact
We'll now try to find a good model to forecast energy consumption for the next twelve months.
Let's start by taking a look at the data to gather some basic information.
Press + to interact
main.py
AEP.csv
import pandas as pdimport matplotlib.pyplot as pltdf = pd.read_csv('AEP.csv')# Changing the datatypedf["Date"] = pd.to_datetime(df['Date'], format='%Y-%m-%d')# Looking at the dataframeprint(df.head())print(df.tail())# Setting the Date as indexdf = df.set_index('Date')# Plottingfig, ax = plt.subplots(figsize=(7, 4.5), dpi=300)ax.plot(df)# Labellingplt.xlabel("Date")plt.ylabel("Megawatts")plt.title("Energy consumption")fig.savefig("output/output.png")plt.close(fig)
First, let's understand the key components of the code.
Line 7: We convert our date column to
datetime
...