Automating the datetime feature extraction with Feature-engine
feature-engine is a Python library for feature engineering and selection that is well suited to working with pandas DataFrames. The DatetimeFeatures() class can extract features from date and time automatically by using pandas’ dt under the hood. DatetimeFeatures() allows you to extract the following features:
- Month
- Quarter
- Semester
- Year
- Week
- Day of the week
- Day of the month
- Day of the year
- Weekend
- Month start
- Month end
- Quarter start
- Quarter end
- Year start
- Year end
- Leap year
- Days in a 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 showcase feature-engine’s functionality, we’ll create a sample DataFrame with a datetime variable:
- Let’s begin by importing
pandasandDatetimeFeatures():import pandas...