0

Similar question being asked in following link.

Pandas offset DatetimeIndex to next business if date is not a business day

Contrast to the answer, is it possible to make it 'fallback' to last business day?

For example, I want to make '2021-07-03' to 2021-07-02' in the following list.

s = pd.bdate_range('2021-04-19', end='2021-7-31', freq=pd.offsets.MonthEnd(1)) + pd.offsets.Day(3)

DatetimeIndex(['2021-05-03', '2021-06-03', '2021-07-03', '2021-08-03'], dtype='datetime64[ns]', freq=None)
  • Using rollback method is working fine, but I do not want to use iteration if it's possible. pd.Series([pd.offsets.BDay(0).rollback(s[i]) for i in range(len(s))]).unique() – Sungmin Son Aug 24 '21 at 01:24

0 Answers0