pandas.tseries.offsets.MonthBegin.is_on_offset#

MonthBegin.is_on_offset(dt)#

Return boolean whether a timestamp intersects with this frequency.

This method determines if a given timestamp aligns with the specific day of the month defined by this offset. For month-based offsets, it checks whether the timestamp’s day matches the expected day according to the offset’s configuration (e.g., start of month, end of month, or first/last business day).

Parameters:
dtdatetime

Timestamp to check intersection with frequency.

Returns:
bool

True if the timestamp is on the offset, False otherwise.

See also

tseries.offsets.MonthBegin

DateOffset of one month at beginning.

tseries.offsets.MonthEnd

DateOffset of one month end.

tseries.offsets.BusinessMonthBegin

DateOffset of one month at the first business day.

tseries.offsets.BusinessMonthEnd

DateOffset of one month at the last business day.

Examples

>>> ts = pd.Timestamp(2022, 1, 1)
>>> pd.offsets.MonthBegin().is_on_offset(ts)
True
>>> ts = pd.Timestamp(2022, 1, 15)
>>> pd.offsets.MonthBegin().is_on_offset(ts)
False
>>> ts = pd.Timestamp(2022, 1, 31)
>>> pd.offsets.MonthEnd().is_on_offset(ts)
True