-
-
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 6 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,9 @@ | |
datetime, | ||
timedelta, | ||
) | ||
from typing import TYPE_CHECKING | ||
from typing import ( | ||
TYPE_CHECKING, | ||
) | ||
import warnings | ||
|
||
from dateutil.relativedelta import ( | ||
|
@@ -169,6 +171,7 @@ def __init__( | |
start_date=None, | ||
end_date=None, | ||
days_of_week: tuple | None = None, | ||
exclude_dates: list[Timestamp] | 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. Actually, can we type this as |
||
) -> None: | ||
""" | ||
Parameters | ||
|
@@ -193,6 +196,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 +263,10 @@ 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 | ||
assert exclude_dates is None or all( | ||
type(ex) == Timestamp for ex in 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. Can you raise a |
||
self.exclude_dates = exclude_dates | ||
|
||
def __repr__(self) -> str: | ||
info = "" | ||
|
@@ -328,6 +338,9 @@ def dates( | |
holiday_dates = holiday_dates[ | ||
(holiday_dates >= filter_start_date) & (holiday_dates <= filter_end_date) | ||
] | ||
|
||
if self.exclude_dates: | ||
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.