How to do it...

Let's begin by importing the necessary libraries and getting the dataset ready:

  1. Let's import the required libraries and function:
import numpy as npimport pandas as pdimport matplotlib.pyplot as pltfrom scipy.signal import find_peaks
  1. Let's load the Appliances energy prediction dataset:
data = pd.read_csv('energydata_complete.csv')
  1. The data type of the date variable is object; let's change it to datetime:
data['date'] = pd.to_datetime(data['date'])
  1. First, let's calculate the time between transactions, that is, the time between each energy record, expressed in minutes:
data['time_since_previous'] = data['date'].diff()data['time_since_previous'] = data['time_since_previous']/np.timedelta64(1,'m')
We discussed the code ...

Get Python Feature Engineering Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.