Extracting Features from Date and Time Variables
Date and time variables are those that contain information about dates, times, or both. In programming, we refer to these variables as datetime
variables. Examples of datetime
variables include date of birth, the time of an event, and date of last payment. The cardinality of datetime
variables is usually very high. This means they contain a multitude of unique values, each corresponding to a specific combination of date and/or time. Therefore, we do not utilize datetime
variables in their raw format in machine learning models. Instead, we enrich the dataset by extracting multiple features from these variables. In this chapter, we will learn how to extract new features from date and time by utilizing the pandas dt
module. Later on, we will automate feature extraction over multiple variables with Feature-engine.
This chapter will cover the following recipes:
- Extracting features from dates with pandas
- Extracting features...