Pandas date_range does not work when using periods and adding holiday · Issue #30593 · pandas-dev/pandas (original) (raw)
pd.date_range(start='2020-11-25 10:00',periods=14,
freq=pd.offsets.CustomBusinessHour(start='10:00'))
pd.date_range(start='2020-11-25 10:00',periods=14,
freq=pd.offsets.CustomBusinessHour(start='10:00',holidays=['2020-11-26']))
DatetimeIndex(['2020-11-25 10:00:00', '2020-11-25 11:00:00',
'2020-11-25 12:00:00', '2020-11-25 13:00:00',
'2020-11-25 14:00:00', '2020-11-25 15:00:00',
'2020-11-25 16:00:00', '2020-11-27 10:00:00',
'2020-11-27 11:00:00', '2020-11-27 12:00:00',
'2020-11-27 13:00:00', '2020-11-27 14:00:00',
'2020-11-27 15:00:00', '2020-11-27 16:00:00',
'2020-11-30 10:00:00', '2020-11-30 11:00:00',
'2020-11-30 12:00:00', '2020-11-30 13:00:00',
'2020-11-30 14:00:00', '2020-11-30 15:00:00',
'2020-11-30 16:00:00', '2020-12-01 10:00:00',
'2020-12-01 11:00:00', '2020-12-01 12:00:00',
'2020-12-01 13:00:00', '2020-12-01 14:00:00',
'2020-12-01 15:00:00', '2020-12-01 16:00:00',
'2020-12-02 10:00:00', '2020-12-02 11:00:00',
'2020-12-02 12:00:00'],
dtype='datetime64[ns]', freq='CBH')
If I replace periods
with the corresponding end
then everything works fine.
pd.date_range(start='2020-11-25 10:00',end='2020-11-27 16:00:00',
freq=pd.offsets.CustomBusinessHour(start='10:00',holidays=['2020-11-26']))
I am not sure why date_range has this weird behavior. Appreciate any help.