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

Time Series / Date functionality Holiday lookup - possible bug #11477

Closed
vlmercado opened this Issue Oct 29, 2015 · 4 comments

Comments

Projects
None yet
3 participants
@vlmercado

vlmercado commented Oct 29, 2015

When trying to confirm if a specific date is an observed holiday using the specific date for the start and end range, the attempt fails to confirm a known observed holiday. It works as expected if I change the end date. When I try to use the same start and end date again, it works every time.

In 2015, the July 4th holiday was observed on July 3rd. Since a BDay() offset ignores holidays, a confirmation of an observed holiday failed when using July 3, 2015 for the start and end dates. See code below:

from datetime import datetime
from pandas.tseries.holiday import get_calendar, HolidayCalendarFactory, GoodFriday

USFedCal = get_calendar('USFederalHolidayCalendar')

USFedCal.holidays(datetime(2015,7,3), datetime(2015,7,3)) # <-- same start and end dates
DatetimeIndex([], dtype='datetime64[ns]', freq=None)

USFedCal.holidays(datetime(2015,7,3), datetime(2015,7,6)) # <-- different start and end dates
DatetimeIndex(['2015-07-03'], dtype='datetime64[ns]', freq=None)

USFedCal.holidays(datetime(2015,7,3), datetime(2015,7,3)) # <-- same start and end dates
DatetimeIndex(['2015-07-03'], dtype='datetime64[ns]', freq=None)
@jreback

This comment has been minimized.

Show comment
Hide comment
@jreback

jreback Oct 29, 2015

Contributor

hmm, that does seem odd.

cc @rockg

Contributor

jreback commented Oct 29, 2015

hmm, that does seem odd.

cc @rockg

@rockg

This comment has been minimized.

Show comment
Hide comment
@rockg

rockg Oct 30, 2015

Contributor

This is a little ugly. Basically since the real holiday is on the 4th, the first call doesn't get the 4th to apply its observance rule to the 3rd (as it's not in the range). The second call spans the 4th so the observance rule can be applied and the third call uses the cache from the second call. I suppose a simple solution is to always move the end date out a few days so that observance rules can be applied and then filtered for the given date range.

Contributor

rockg commented Oct 30, 2015

This is a little ugly. Basically since the real holiday is on the 4th, the first call doesn't get the 4th to apply its observance rule to the 3rd (as it's not in the range). The second call spans the 4th so the observance rule can be applied and the third call uses the cache from the second call. I suppose a simple solution is to always move the end date out a few days so that observance rules can be applied and then filtered for the given date range.

@rockg

This comment has been minimized.

Show comment
Hide comment
@rockg

rockg Oct 30, 2015

Contributor

That seems to work fine. Will submit the PR tomorrow morning as I came across a few more things that were odd.

Contributor

rockg commented Oct 30, 2015

That seems to work fine. Will submit the PR tomorrow morning as I came across a few more things that were odd.

@rockg

This comment has been minimized.

Show comment
Hide comment
@rockg

rockg Oct 30, 2015

Contributor

This seems a little counterintuitive but it makes sense to me:

USFederalHolidayCalendar().holidays(datetime(2015, 7, 3), datetime(2015, 7, 3))
DatetimeIndex(['2015-07-03'], dtype='datetime64[ns]', freq=None)

USFederalHolidayCalendar().holidays(datetime(2015, 7, 4), datetime(2015, 7, 4))
Index([], dtype='object')
Contributor

rockg commented Oct 30, 2015

This seems a little counterintuitive but it makes sense to me:

USFederalHolidayCalendar().holidays(datetime(2015, 7, 3), datetime(2015, 7, 3))
DatetimeIndex(['2015-07-03'], dtype='datetime64[ns]', freq=None)

USFederalHolidayCalendar().holidays(datetime(2015, 7, 4), datetime(2015, 7, 4))
Index([], dtype='object')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment