Automating feature extraction with Feature-engine
Feature-engine is a Python library dedicated to engineering and selecting features and is well-suited to working with pandas DataFrames. The DatetimeFeatures()
class from Feature-engine can extract features from date and time automatically by using the pandas dt
module under the hood. This transformer allows you to extract the following features:
- Month
- Quarter
- Semester
- Year
- Week
- Day of week
- Day of month
- Day of year
- Weekend
- Month start
- Month end
- Quarter start
- Quarter end
- Year start
- Year end
- Leap year
- Days in month
- Hour
- Minute
- Second
In this recipe, we will automatically create features from date and time by utilizing Feature-engine.
How to do it...
To proceed with this recipe, we must import the necessary libraries and create a toy dataset:
- Let’s begin by importing
pandas
andDatetimeFeatures()
:import pandas as pd from feature_engine...