DateOffsets can be created to move dates by a specified number of valid dates. For example, Bday (2) can be added to a date to move it two business days forward. If the date does not start with a valid date, it is first moved to a valid date and then an offset is generated.
tseries.offsets.BusinessHour () is used to create a business hour offset.
Syntax: pandas.tseries. offsets.BusinessHour (n = 1, normalize = False, start = ’09: 00 ′, end = ’17: 00 ′, offset = datetime.timedelta (0))
n: number of hours
normalize: Whether to round the result of a DateOffset addition down to the previous midnight.
start: start time
end: end time
offset: offset from the given date
Example # 1: Use
pandas.tseries.offsets.BusinessHour () to create an offset in 5
pandas.tse ries.offsets.BusinessHour () hours.
We will now add a business hour offset to this timestamp object to increase the datetime.
As we can see from the output, we have successfully created an offset of 5 business hours and added it to the given timestamp.
Example # 2: Use
pandas.tseries.offsets.BusinessHour () to create an offset of 10 days and 5
pandas.tseries.offsets.BusinessHour () hours.
Now we will add the work hour offset to given a timestamp object to increment the datetime value.
As we can see in the output, we have successfully created an offset and added it to the given timestamp.