BUG: CustomBusinessHour is to capturing last business hour defined by end parameter

This issue has been created since 2022-11-22.

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • 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

INSTALLED VERSIONS

commit : 91111fd
python : 3.9.2.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19041
machine : AMD64
processor : Intel64 Family 6 Model 165 Stepping 5, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252

pandas : 1.5.1
numpy : 1.23.4
pytz : 2022.2.1
dateutil : 2.8.2
setuptools : 65.3.0
pip : 22.2.2
Cython : None
pytest : 7.2.0
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : 3.0.3
lxml.etree : 4.9.1
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.4.0
pandas_datareader: None
bs4 : 4.11.1
bottleneck : None
brotli :
fastparquet : None
fsspec : 2022.8.2
gcsfs : None
matplotlib : 3.6.1
numba : None
numexpr : None
odfpy : None
openpyxl : 3.0.10
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : 1.0.10
s3fs : None
scipy : 1.8.1
snappy : None
sqlalchemy : 1.4.40
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : 2022.2

Eikinho wrote this answer on 2022-11-22

take

More Details About Repo
Owner Name pandas-dev
Repo Name pandas
Full Name pandas-dev/pandas
Language Python
Created Date 2010-08-24
Updated Date 2022-12-07
Star Count 36164
Watcher Count 1118
Fork Count 15472
Issue Count 3683

YOU MAY BE INTERESTED

Issue Title Created Date Comment Count Updated Date
Add back the VPNDialog to allow Android applications running in the subsystem to request to set up VPNs 1 2022-11-23 2022-12-07
Exception happens when trying to access swaggerui running in docker 1 2022-11-02 2022-11-26
Split String and convert into Array of Object 0 2021-11-11 2022-10-06
Remove SwaggerUI as direct dependency 0 2022-08-23 2022-11-17
Traning data for MVP 1 2022-04-29 2022-11-28
build success, but cannot run 8 2022-07-11 2022-11-28
Document our testing guidelines 1 2021-08-14 2022-11-19
NewbieGuide +ImmersionBar 位置错乱 2 2021-03-26 2022-11-29
number of genes in tl.rank_velocity_genes result 5 2022-04-12 2022-11-28
Is it possible to open pdf files using external apps? 0 2022-03-30 2022-11-08
❓ Android resolution and FPS setting 1 2022-01-26 2022-10-27
assumes origin 0 2021-05-04 2021-11-13
Cursor jumps when switching split-screen tabs 2 2021-11-23 2022-10-27
New sanity project compiles with errors, studio shows unhandled error. 2 2021-12-06 2022-10-05
Lucene query parsing error when using terms filter 2 2022-09-17 2022-09-29
`--core.cache.seed-on-startup=false` doesn't work 2 2022-06-15 2022-11-22
Marshal Loads Failed 1 2021-05-16 2022-11-01
Make `app.openshift.io/runtime` an annotation 3 2021-10-06 2022-12-06
[BUG] Log scale plots raise warning and break subsequent non-log scale plots 1 2021-11-02 2022-10-16
[BUG] connect: Connection refused GKS: can't connect to GSK socket application = julia crashes hard 2 2021-11-02 2022-10-24
Generated diagram isn't loading all models 2 2020-11-09 2022-11-29
'MedidataCredential.h' file not found 1 2021-07-08 2022-10-05
[Bug] Ray 1.8.0 [Default] does not contain dashboard when installing with pip3 on ubuntu server 12 2021-11-24 2022-11-22
date_input fails to initialize from sessionstate if today's date is not in the range [min_value, max_value] 4 2022-06-22 2022-11-22
why do you perform down sampling after the first layer in 3detr-m, rather than the whole encoder? 2 2022-04-24 2022-11-27
`util-http` breaks auto-instrumentation since v0.25b0 2 2021-10-15 2022-09-25
make prepare-local-env ends in ssl handshake exception while installing gradle 6 2021-11-18 2022-09-21
Create a new Pairing Code 0 2022-08-16 2022-08-09
Community Information not found 4 2021-10-22 2022-11-03
Crash when tapping on push notification about starter pack arrival 1 2021-10-19 2022-11-04
Don't load data from NVD for RoP 0 2021-07-27 2022-11-13
Add support for 'Due date' field 0 2021-03-10 2022-11-30
Plugin broken? 12 2019-06-30 2022-01-17
How to create QR code in website 3 2021-10-31 2022-12-04
Hangs on errors. 0 2021-02-11 2022-01-05
Issue when debugging extension 0 2021-08-10 2021-09-19
Align tensorboard log curves when batch_size and number of gpus not equal. 2 2021-09-13 2022-11-15
Update i18n 1 2018-06-11 2022-01-02
urllib.error.URLError: certificate verify failed on macOS 4 2022-01-13 2022-10-11
simple repro for lightgbm.basic.LightGBMError: Check failed: (best_split_info.left_count) > (0) 4 2021-10-28 2022-11-16
Schema compare doesn't check if result is valid 0 2021-05-04 2022-10-25
Feedback/comment 1 2019-12-05 2022-01-07
UniXcoder - Testing the model 1 2022-04-19 2022-11-30
Support Service Principal Authentication 6 2020-08-11 2022-11-29
Issue: java.util.concurrent.TimeoutException: Futures timed out after [5 minutes] 1 2020-10-20 2022-11-29
Connection timeout after 300000 ms idle/inactive 1 2020-09-15 2022-11-29
Error: java.lang.IllegalArgumentException: requirement failed: partitions(13).partition == 14, but it should equal 13 1 2020-11-24 2022-11-29
bug: TypeError: Cannot read properties of undefined (reading 'map') 4 2022-12-06 2022-11-29
Support Dark Mode (Transparent SVG) 0 2022-06-27 2022-11-23
Failed to install CRD on k8s 1.15 1 2021-09-29 2022-12-03