pandas.tseries.offsets.CustomBusinessHour.is_on_offset#
- CustomBusinessHour.is_on_offset(dt)#
Return boolean whether a timestamp intersects with this frequency.
This method determines if a given timestamp falls within business hours. Business hours are defined by the
startandendparameters (default 09:00 to 17:00). The timestamp must also fall on a business day (Monday through Friday). Ifnormalizeis True, it also checks that the time component is midnight.- Parameters:
- dtdatetime
Timestamp to check intersection with frequency.
- Returns:
- bool
True if the timestamp is within business hours, False otherwise.
See also
tseries.offsets.BusinessHourRepresents business hour offset.
tseries.offsets.BusinessDay.is_on_offsetCheck if a timestamp is on a business day.
Examples
>>> ts = pd.Timestamp(2022, 8, 5, 10) >>> ts.day_name() 'Friday' >>> pd.offsets.BusinessHour().is_on_offset(ts) True
>>> ts = pd.Timestamp(2022, 8, 5, 20) >>> pd.offsets.BusinessHour().is_on_offset(ts) False
>>> ts = pd.Timestamp(2022, 8, 6, 10) >>> ts.day_name() 'Saturday' >>> pd.offsets.BusinessHour().is_on_offset(ts) False