...

/

Energy Consumption

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 pd
import matplotlib.pyplot as plt
df = pd.read_csv('AEP.csv')
# Changing the datatype
df["Date"] = pd.to_datetime(df['Date'], format='%Y-%m-%d')
# Looking at the dataframe
print(df.head())
print(df.tail())
# Setting the Date as index
df = df.set_index('Date')
# Plotting
fig, ax = plt.subplots(figsize=(7, 4.5), dpi=300)
ax.plot(df)
# Labelling
plt.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 ...