-
-
Notifications
You must be signed in to change notification settings - Fork 18.6k
DOC/ENH: Holiday exclusion argument #61600
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
Changes from 13 commits
f054afb
5a809e2
891b442
aa08735
f019a5c
bdbb555
5bca8c7
655ca4e
f46c394
27cca3d
a9a745c
7710e43
5cfd599
2d9e4c5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,6 +169,7 @@ def __init__( | |
start_date=None, | ||
end_date=None, | ||
days_of_week: tuple | None = None, | ||
exclude_dates: DatetimeIndex | None = None, | ||
) -> None: | ||
""" | ||
Parameters | ||
|
@@ -193,6 +194,8 @@ class from pandas.tseries.offsets, default None | |
days_of_week : tuple of int or dateutil.relativedelta weekday strs, default None | ||
Provide a tuple of days e.g (0,1,2,3,) for Monday Through Thursday | ||
Monday=0,..,Sunday=6 | ||
exclude_dates : DatetimeIndex or default None | ||
Specific dates to exclude e.g. skipping a specific year's holiday | ||
|
||
Examples | ||
-------- | ||
|
@@ -257,6 +260,9 @@ class from pandas.tseries.offsets, default None | |
self.observance = observance | ||
assert days_of_week is None or type(days_of_week) == tuple | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should I also switch this to throw a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A separate PR would be better, thanks. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For this, should I open a new issue? Or just make another PR? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just another PR is fine |
||
self.days_of_week = days_of_week | ||
if not (exclude_dates is None or isinstance(exclude_dates, DatetimeIndex)): | ||
raise ValueError("exclude_dates must be None or of type DatetimeIndex.") | ||
mroeschke marked this conversation as resolved.
Show resolved
Hide resolved
|
||
self.exclude_dates = exclude_dates | ||
|
||
def __repr__(self) -> str: | ||
info = "" | ||
|
@@ -328,6 +334,9 @@ def dates( | |
holiday_dates = holiday_dates[ | ||
(holiday_dates >= filter_start_date) & (holiday_dates <= filter_end_date) | ||
] | ||
|
||
if self.exclude_dates is not None: | ||
holiday_dates = holiday_dates.difference(self.exclude_dates) | ||
if return_name: | ||
return Series(self.name, index=holiday_dates) | ||
return holiday_dates | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you construct the resulting
DatetimeIndex
and usetm.assert_index_equal
i.e.And below as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the tm.assert_index_equal() in addition to the above 3 asserts, hopefully that is okay? I can also delete the 3 assert statements from above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes could you delete the 3 assert statements in this test and below? Hardcoding the expected result and using
tm.assert_index.equal
is a stronger assertion than these statements