Calculating new dates using offsets
Frequencies in pandas are represented using date offsets. We have touched on this concept at the beginning of the chapter when discussing Timedelta
objects. pandas extends the capabilities of these using the concept of DateOffset
objects. They are objects which represent knowledge of how to integrate time offsets and frequencies relative to DatetimeIndex
objects.
Representing data intervals with date offsets
DatetimeIndex
objects are created at various frequencies by using passing frequency strings such as 'M'
, 'W'
, and 'BM'
using the freq
parameter of pd.date_range()
. Under the hood, these frequency strings are translated into an instance of the pandas DateOffset
object.
A DateOffset
represents a regular frequency increment. Specific date offset logic, such as "month", "business day", or "hour", is represented in pandas with various subclasses of DateOffset
. A DateOffset
provides pandas with the intelligence to be able to determine how to calculate a specific...