Skip to content

Weekmask & holidays error in CustomBusinessHour #23542

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mnpica opened this issue Nov 7, 2018 · 3 comments · Fixed by #41712
Closed

Weekmask & holidays error in CustomBusinessHour #23542

mnpica opened this issue Nov 7, 2018 · 3 comments · Fixed by #41712
Labels
good first issue Needs Tests Unit test(s) needed to prevent regressions
Milestone

Comments

@mnpica
Copy link

mnpica commented Nov 7, 2018

Code Sample, a copy-pastable example if possible

from pandas.tseries.offsets import CustomBusinessDay, CustomBusinessHour
import pandas as pd
import datetime

weekmask = 'Mon Tue Wed Thu Fri Sat'
holidays=['2018-11-09']
bday = CustomBusinessDay(weekmask=weekmask,holidays=holidays)
dt=datetime.datetime(2018,11,8)
print dt+1*bday
# Holidays keyword is supported. 
# Output: Timestamp('2018-11-10 00:00:00')

bh = CustomBusinessHour(start='08:00', end='17:00', weekmask=weekmask,holidays=holidays)
print pd.Timestamp('2018-11-08 08:00')+10*bh
# Expected output: 2018-11-10 09:00:00 ,holidays keyword is not supported.
# Output:Timestamp('2018-11-09 09:00:00')

print pd.Timestamp('2018-11-08 08:00')+18*bh
# Seems right?
# Timestamp('2018-11-12 08:00:00')

bh = CustomBusinessHour(start='08:00', end='17:00', weekmask='Tue Wed Thu Fri Sat',holidays=holidays)
print pd.Timestamp('2018-11-08 08:00')+18*bh
# Expected output: 2018-11-13 08:00:00, weekmask keyword is not supported.
# Timestamp('2018-11-12 08:00:00')

Problem description

  1. Could Saturday be set as weekday?
  2. Could I use weekmask / holidays by CustomBusinessHour?

Expected Output

Output of pd.show_versions()

INSTALLED VERSIONS ------------------ commit: None python: 2.7.15.final.0 python-bits: 64 OS: Windows OS-release: 10 machine: AMD64 processor: Intel64 Family 6 Model 142 Stepping 9, GenuineIntel byteorder: little LC_ALL: None LANG: None LOCALE: None.None

pandas: 0.21.0
pytest: None
pip: 10.0.1
setuptools: 39.0.1
Cython: 0.27.3
numpy: 1.15.0
scipy: 1.0.0
pyarrow: None
xarray: None
IPython: 5.5.0
sphinx: None
patsy: None
dateutil: 2.6.1
pytz: 2017.3
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: 2.2.2
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: 1.0.2
lxml: None
bs4: None
html5lib: 1.0b10
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.9.6
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

@gfyoung gfyoung added Usage Question Timedelta Timedelta data type labels Nov 7, 2018
@gfyoung
Copy link
Member

gfyoung commented Nov 7, 2018

cc @jreback

@mroeschke mroeschke added Bug Frequency DateOffsets and removed Timedelta Timedelta data type Usage Question labels May 3, 2020
@mroeschke
Copy link
Member

This looks fixed on master. Could use a test

In [36]: bh = CustomBusinessHour(start='08:00', end='17:00', weekmask=weekmask,holidays=holidays)
    ...:

In [37]:  pd.Timestamp('2018-11-08 08:00')+10*bh
Out[37]: Timestamp('2018-11-10 09:00:00')

In [38]: bh = CustomBusinessHour(start='08:00', end='17:00', weekmask='Tue Wed Thu Fri Sat',holidays=holidays)
    ...:

In [39]: pd.Timestamp('2018-11-08 08:00')+18*bh
Out[39]: Timestamp('2018-11-13 08:00:00')

@mroeschke mroeschke added good first issue Needs Tests Unit test(s) needed to prevent regressions and removed Bug Frequency DateOffsets labels Jun 28, 2020
@TomDL1995
Copy link

TomDL1995 commented Aug 10, 2020

Looking for a first issue and come across this. Was looking for existing tests to get some inspiration but it seems that there already exist tests for both CustomBusinessHour and CustomBusinessDay (see pandas/tests/tseries/offsets/test_offsets.py).

Is there still anything left to do?

@mroeschke mroeschke mentioned this issue May 29, 2021
15 tasks
@mroeschke mroeschke added this to the 1.3 milestone May 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Needs Tests Unit test(s) needed to prevent regressions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants