pythonintermediate

Pandas Business Day Offsets

Compute business-day-adjusted dates using pandas offsets for financial and SLA calculations.

python
import pandas as pd
from pandas.tseries.offsets import BDay, BusinessMonthEnd, QuarterEnd

today = pd.Timestamp('2024-03-15')

print('Next bday:         ', today + BDay(1))
print('5 bdays later:     ', today + BDay(5))
print('Business month end:', today + BusinessMonthEnd())
print('Quarter end:       ', today + QuarterEnd())

dates = pd.date_range('2024-01-01', periods=10, freq='B')  # Business days
print(dates)

Use Cases

  • financial calendars
  • SLA deadlines
  • settlement dates

Tags

Related Snippets

Similar patterns you can reuse in the same workflow.