Monday, 30 November 2020

Why does adding CDay() to DatetimeIndex include a weekend?

I am on pandas version 1.1.3.

Suppose I have the following index

import pandas as pd
from pandas.tseries.offsets import CDay

idx = pd.bdate_range("2010-02-03","2010-02-12") + pd.Timedelta('22H')

If I then add:

shifted_idx = idx + 0*CDay(offset=pd.Timedelta('4H'))

I would expect the timestamp in idx of 2010-05-05 22:00 to move to 2010-05-08 02:00 since CDay() has weekmask = ‘Mon Tue Wed Thu Fri’ by default.

However, we see in shifted_idx a timestamp 2010-02-06 02:00:00 which is on a Saturday and violates the weekmask?



from Why does adding CDay() to DatetimeIndex include a weekend?

No comments:

Post a Comment