Pandas version checks
-
[X] I have checked that this issue has not already been reported.
-
[X] I have confirmed this bug exists on the latest version of pandas.
-
[X] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
import datetime as dt
freq = pd.offsets.CustomBusinessHour(weekmask="Sat Sun", start="00:00", end="16:00")
pd.date_range(dt.datetime(2020,1,1), dt.datetime(2020,1,15), freq=freq)
Issue Description
Expected to return every hour of a day from midnight to 16:00, but when including end='16:00' that last hour isn't captured. Per the doc it states that end defaults to '16:00'. You can put any hour for end and it doesn't capture that final hour.
DatetimeIndex(['2020-01-04 00:00:00', '2020-01-04 01:00:00',
'2020-01-04 02:00:00', '2020-01-04 03:00:00',
'2020-01-04 04:00:00', '2020-01-04 05:00:00',
'2020-01-04 06:00:00', '2020-01-04 07:00:00',
'2020-01-04 08:00:00', '2020-01-04 09:00:00',
'2020-01-04 10:00:00', '2020-01-04 11:00:00',
'2020-01-04 12:00:00', '2020-01-04 13:00:00',
'2020-01-04 14:00:00', '2020-01-04 15:00:00',
'2020-01-05 00:00:00', '2020-01-05 01:00:00',
'2020-01-05 02:00:00', '2020-01-05 03:00:00',
'2020-01-05 04:00:00', '2020-01-05 05:00:00',
'2020-01-05 06:00:00', '2020-01-05 07:00:00',
'2020-01-05 08:00:00', '2020-01-05 09:00:00',
'2020-01-05 10:00:00', '2020-01-05 11:00:00',
'2020-01-05 12:00:00', '2020-01-05 13:00:00',
'2020-01-05 14:00:00', '2020-01-05 15:00:00',
'2020-01-11 00:00:00', '2020-01-11 01:00:00',
'2020-01-11 02:00:00', '2020-01-11 03:00:00',
'2020-01-11 04:00:00', '2020-01-11 05:00:00',
'2020-01-11 06:00:00', '2020-01-11 07:00:00',
'2020-01-11 08:00:00', '2020-01-11 09:00:00',
'2020-01-11 10:00:00', '2020-01-11 11:00:00',
'2020-01-11 12:00:00', '2020-01-11 13:00:00',
'2020-01-11 14:00:00', '2020-01-11 15:00:00',
'2020-01-12 00:00:00', '2020-01-12 01:00:00',
'2020-01-12 02:00:00', '2020-01-12 03:00:00',
'2020-01-12 04:00:00', '2020-01-12 05:00:00',
'2020-01-12 06:00:00', '2020-01-12 07:00:00',
'2020-01-12 08:00:00', '2020-01-12 09:00:00',
'2020-01-12 10:00:00', '2020-01-12 11:00:00',
'2020-01-12 12:00:00', '2020-01-12 13:00:00',
'2020-01-12 14:00:00', '2020-01-12 15:00:00'],
dtype='datetime64[ns]', freq='CBH')
Expected Behavior
import pandas as pd import datetime as dt freq = pd.offsets.CustomBusinessHour(weekmask="Sat Sun", start="00:00", end="16:00") pd.date_range(dt.datetime(2020,1,1), dt.datetime(2020,1,15), freq=freq)
Expected:
DatetimeIndex(['2020-01-04 00:00:00', '2020-01-04 01:00:00',
'2020-01-04 02:00:00', '2020-01-04 03:00:00',
'2020-01-04 04:00:00', '2020-01-04 05:00:00',
'2020-01-04 06:00:00', '2020-01-04 07:00:00',
'2020-01-04 08:00:00', '2020-01-04 09:00:00',
'2020-01-04 10:00:00', '2020-01-04 11:00:00',
'2020-01-04 12:00:00', '2020-01-04 13:00:00',
'2020-01-04 14:00:00', '2020-01-04 15:00:00',
'2020-01-04 16:00:00', '2020-01-05 00:00:00',
'2020-01-05 01:00:00', '2020-01-05 02:00:00',
'2020-01-05 03:00:00', '2020-01-05 04:00:00',
'2020-01-05 05:00:00', '2020-01-05 06:00:00',
'2020-01-05 07:00:00', '2020-01-05 08:00:00',
'2020-01-05 09:00:00', '2020-01-05 10:00:00',
'2020-01-05 11:00:00', '2020-01-05 12:00:00',
'2020-01-05 13:00:00', '2020-01-05 14:00:00',
'2020-01-05 15:00:00', '2020-01-05 16:00:00',
'2020-01-11 00:00:00', '2020-01-11 01:00:00',
'2020-01-11 02:00:00', '2020-01-11 03:00:00',
'2020-01-11 04:00:00', '2020-01-11 05:00:00',
'2020-01-11 06:00:00', '2020-01-11 07:00:00',
'2020-01-11 08:00:00', '2020-01-11 09:00:00',
'2020-01-11 10:00:00', '2020-01-11 11:00:00',
'2020-01-11 12:00:00', '2020-01-11 13:00:00',
'2020-01-11 14:00:00', '2020-01-11 15:00:00',
'2020-01-11 16:00:00', '2020-01-12 00:00:00',
'2020-01-12 01:00:00', '2020-01-12 02:00:00',
'2020-01-12 03:00:00', '2020-01-12 04:00:00',
'2020-01-12 05:00:00', '2020-01-12 06:00:00',
'2020-01-12 07:00:00', '2020-01-12 08:00:00',
'2020-01-12 09:00:00', '2020-01-12 10:00:00',
'2020-01-12 11:00:00', '2020-01-12 12:00:00',
'2020-01-12 13:00:00', '2020-01-12 14:00:00',
'2020-01-12 15:00:00', '2020-01-12 16:00:00'],
dtype='datetime64[ns]', freq='CBH')
Installed Versions
Comment From: Eikinho
take
Comment From: natmokval
Hi @Eikinho. Do you mind if I will work on this issue as well?
Comment From: natmokval
I am not sure that there is a problem here. It looks like expected behavior. The return value contains the beginning of every business hour. That is why 16:00
is not included in this case.
The example from the issue description may be useful to clarify the behavior of CustomBusinessHour
. Probably, documentation for CustomBusinessHour can be updated. @MarcoGorelli, what do you think?
Comment From: MarcoGorelli
Agree that this looks expected - and sure, an extra example to clarify would be great, the docs are quite sparse on this at the moment