-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating
Python Feature Engineering Cookbook - Second Edition
By :
datetime variables can take dates, time, or dates and time as values. They are not used in their raw format to build machine learning algorithms. Instead, we create additional features from them, and we can enrich the dataset dramatically by extracting information from the date and time.
The pandas Python library contains a lot of capabilities for working with dates and time. pandas dt is the accessor object to the datetime properties of a pandas Series. To access the pandas dt functionality, the variables should be cast in a data type that supports these operations, such as datetime or timedelta.
Tip
Often, the datetime variables are cast as objects, particularly when the data is loaded from a CSV file. Therefore, to extract the date and time features that we will discuss throughout this chapter, it is necessary to recast the variables as datetime.
In this recipe, we will learn how to extract features from dates by utilizing pandas...