Search code examples
pythondateweekday

Change pandas date by workdays


I would like to increase the date in my pandas column by 1 workday, that is, if the date is a Monday, Jan 21st, I want to change it to Tuesday, Jan 22nd, but if the date is Friday Jan 25th, then I want to increase it to Monday Jan 28th.

This is what I would do to do the simple version of just increasing it by 1 day:

new_date = old_date + datetime.timedelta(days=+1)

Is there a function that accounts for workdays?


Solution

  • You could just use this,

    from pandas.tseries.offsets import BDay
    new_date = old_date + BDay(1)
    

    more info here