Let's begin by importing the libraries and getting the data set ready:
- Let's import the required libraries and function:
import numpy as npimport pandas as pd
import matplotlib.pyplot as pltfrom scipy.signal import find_peaks
- Let's load the Appliances energy prediction dataset:
data = pd.read_csv('energydata_complete.csv')
- The data type of the date variable is object; let's change it to datetime:
data['date'] = pd.to_datetime(data['date'])
- Now, we need to extract the day, month, and hour part from the datetime variable into new columns:
data[['day', 'month', 'hr']] = pd.DataFrame([(x.day, x.month, x.hour) for x in data['date']])