6

Extracting Features from Date and Time Variables

Date and time variables contain information about dates, times, or both, and in programming, we refer to them collectively as datetime features. Date of birth, the time of an event, and the date and time of the last payment are examples of datetime variables.

Because of their nature, datetime features typically exhibit high cardinality. This means that they contain a huge number of unique values, each corresponding to a specific date and/or time combination. We don’t normally use datetime variables for machine learning models in their raw format. Instead, we enrich the dataset by extracting multiple features from these variables. These new features will typically have reduced cardinality, and ...

Get Python Feature Engineering Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.