-
-
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 2 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 | ||||
---|---|---|---|---|---|---|
|
@@ -4,7 +4,10 @@ | |||||
datetime, | ||||||
timedelta, | ||||||
) | ||||||
from typing import TYPE_CHECKING | ||||||
from typing import ( | ||||||
TYPE_CHECKING, | ||||||
Any, | ||||||
) | ||||||
import warnings | ||||||
|
||||||
from dateutil.relativedelta import ( | ||||||
|
@@ -169,6 +172,7 @@ def __init__( | |||||
start_date=None, | ||||||
end_date=None, | ||||||
days_of_week: tuple | None = None, | ||||||
exclude_dates: list[Any] | None = None, | ||||||
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.
Suggested change
Let's make the users do the |
||||||
) -> None: | ||||||
""" | ||||||
Parameters | ||||||
|
@@ -193,6 +197,9 @@ 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 : list of datetime-likes or | ||||||
single datetime-like, default None | ||||||
Specific dates to exclude e.g. skipping a specific year's holiday | ||||||
|
||||||
Examples | ||||||
-------- | ||||||
|
@@ -257,6 +264,11 @@ 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 | ||||||
self.exclude_dates = ( | ||||||
[Timestamp(ex) for ex in exclude_dates] | ||||||
if exclude_dates is not None | ||||||
else exclude_dates | ||||||
) | ||||||
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. With the constructor argument being stricter, we can just validate the arguments are all |
||||||
|
||||||
def __repr__(self) -> str: | ||||||
info = "" | ||||||
|
@@ -328,6 +340,12 @@ def dates( | |||||
holiday_dates = holiday_dates[ | ||||||
(holiday_dates >= filter_start_date) & (holiday_dates <= filter_end_date) | ||||||
] | ||||||
|
||||||
if self.exclude_dates: | ||||||
holiday_dates = DatetimeIndex( | ||||||
[hd for hd in holiday_dates if hd not in self.exclude_dates] | ||||||
) | ||||||
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.
|
||||||
|
||||||
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.
Can you move this to
v3.0.0.rst
?