You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Your code here# Labor Day calendarimportpandasaspdfrompandas.tseries.holidayimportAbstractHolidayCalendar, USLaborDayclasstestCalendar(AbstractHolidayCalendar):
rules= [
USLaborDay,
]
cal=testCalendar()
workDay=pd.offsets.CustomBusinessDay(calendar=cal)
# Print dates of Labor Dayforyrin [2021, 2032]:
print("Labor day", yr, "is on ", cal.holidays(pd.to_datetime(str(yr-1)+'-12-31'),
pd.to_datetime(str(yr) +'-12-31')))
print("\n")
# Check next working day for Saturday before Labor DayfordateTextin ['2021-09-04', '2032-09-04']:
date=pd.to_datetime(dateText)
print(dateText, "is a", date.strftime('%A') +". Roll forward to", date+0*workDay)
Problem description
Here's the output:
Labor day 2021 is on DatetimeIndex(['2021-09-06'], dtype='datetime64[ns]', freq='WOM-1MON')
Labor day 2032 is on DatetimeIndex(['2032-09-06'], dtype='datetime64[ns]', freq='WOM-1MON')
2021-09-04 is a Saturday. Roll forward to 2021-09-07 00:00:00
2032-09-04 is a Saturday. Roll forward to 2032-09-06 00:00:00
The calendar knows that Labor day is on Monday, Sept. 6 in both 2021 and 2032. However, when I ask to move to the next working day from Saturday, Sept. 4, I get the (correct) answer Sept.7 for 2021, but the (wrong) answer Sept 6 (which is Labor Day) for 2032.
Is this a bug, or am I doing something wrong?
Thanks.
Note: We receive a lot of issues on our GitHub tracker, so it is very possible that your issue has been posted before. Please check first before submitting so that we do not have to handle and close duplicates!
Note: Many problems can be resolved by simply upgrading pandas to the latest version. Before submitting, please check if that solution works for you. If possible, you may want to check if master addresses this issue, but that is not necessary.
For documentation-related issues, you can check the latest versions of the docs on master here:
tseries.holidays gets relatively little attention, so it is entirely plausible that this is a bug.
I've got a guess as to the cause, would like you to confirm. Is it the case that the behavior is correct for 2030 but broken for 2031? And correct for 1970 but broken for 1969?
That's good news indeed. Then I'm pretty sure the issue is caued by the start_date and end_date defined on L348-349 of tseries.holiday. Extending those dates out further will probably fix this problem. That might come with a performance penalty (or else I expect the original author would have had these go out further in the first place), so it isn't obvious how far out they should be extended.
Code Sample, a copy-pastable example if possible
Problem description
Here's the output:
Labor day 2021 is on DatetimeIndex(['2021-09-06'], dtype='datetime64[ns]', freq='WOM-1MON')
Labor day 2032 is on DatetimeIndex(['2032-09-06'], dtype='datetime64[ns]', freq='WOM-1MON')
2021-09-04 is a Saturday. Roll forward to 2021-09-07 00:00:00
2032-09-04 is a Saturday. Roll forward to 2032-09-06 00:00:00
The calendar knows that Labor day is on Monday, Sept. 6 in both 2021 and 2032. However, when I ask to move to the next working day from Saturday, Sept. 4, I get the (correct) answer Sept.7 for 2021, but the (wrong) answer Sept 6 (which is Labor Day) for 2032.
Is this a bug, or am I doing something wrong?
Thanks.
Note: We receive a lot of issues on our GitHub tracker, so it is very possible that your issue has been posted before. Please check first before submitting so that we do not have to handle and close duplicates!
Note: Many problems can be resolved by simply upgrading
pandas
to the latest version. Before submitting, please check if that solution works for you. If possible, you may want to check ifmaster
addresses this issue, but that is not necessary.For documentation-related issues, you can check the latest versions of the docs on
master
here:https://pandas-docs.github.io/pandas-docs-travis/
If the issue has not been resolved there, go ahead and file it in the issue tracker.
Expected Output
Output of
pd.show_versions()
[paste the output of
pd.show_versions()
here below this line]INSTALLED VERSIONS
commit: None
python: 3.7.3.final.0
python-bits: 64
OS: Darwin
OS-release: 17.7.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
pandas: 0.24.2
pytest: 5.0.1
pip: 19.1.1
setuptools: 41.0.1
Cython: 0.29.12
numpy: 1.16.4
scipy: 1.3.0
pyarrow: None
xarray: None
IPython: 7.6.1
sphinx: 2.1.2
patsy: 0.5.1
dateutil: 2.8.0
pytz: 2019.1
blosc: None
bottleneck: 1.2.1
tables: 3.5.2
numexpr: 2.6.9
feather: None
matplotlib: 3.1.0
openpyxl: 2.6.2
xlrd: 1.2.0
xlwt: 1.3.0
xlsxwriter: 1.1.8
lxml.etree: 4.3.4
bs4: 4.7.1
html5lib: 1.0.1
sqlalchemy: 1.3.5
pymysql: None
psycopg2: None
jinja2: 2.10.1
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None
gcsfs: None
The text was updated successfully, but these errors were encountered: