pandas.tseries.offsets.DateOffset.is_on_offset#
- DateOffset.is_on_offset(dt)#
Return boolean whether a timestamp intersects with this frequency.
For DateOffset, the check is straightforward: it returns True for any timestamp, unless normalize is True, in which case it verifies that the timestamp is at midnight (normalized to the start of the day).
- Parameters:
- dtdatetime
Timestamp to check.
- Returns:
- bool
True if the timestamp intersects with this frequency.
See also
DateOffset.rollforwardRoll provided date forward to next offset.
DateOffset.rollbackRoll provided date backward to previous offset.
Examples
>>> ts = pd.Timestamp(2022, 1, 1) >>> freq = pd.DateOffset(months=2) >>> freq.is_on_offset(ts) True
>>> ts = pd.Timestamp(2022, 1, 1, 12, 0, 0) >>> freq = pd.DateOffset(months=2, normalize=True) >>> freq.is_on_offset(ts) False