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.BusinessDay.rollback()
Pandas tseries.offsets.BusinessDay.rollback()
specified date back to next offset, unless offset.
Syntax : pandas.tseries.offsets.BusinessDay.rollback (dt)
Parameter:
dt: dtReturns: Timestamp
Example # 1: Use pandas.tseries.offsets.BusinessDay.rollback ( )
to flip the supplied date back to the next offset, if not at an offset.
|
Output:
Now we will add a desktop offset days to the given timestamp object to increment the datetime value. We’ll also roll the provided date back to the next offset, if not at the offset.
|
Output:
As we can see from the output, we have successfully created an offset of 5 business days and added it to the given timestamp. We’ve also rolled back the provided date back to the next offset, if not by offset.
Example # 2: Use pandas.tseries.offsets.BusinessDay.rollback ()
to flip the supplied date back to the next offset, if not at an offset.
|
Output:
Now we will add a workday offset to the given my timestamp object to increment the datetime value. We’ll also roll the provided date back to the next offset, if not at the offset.
|
Output:
As we can see from the output, we have successfully created an offset of 10 business days and 10 hours and added it to the given time stamp. We’ve also rolled the provided date back to the next offset, if not the offset.