Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions doc/source/whatsnew/v3.0.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ Other enhancements
- :class:`ArrowDtype` now supports ``pyarrow.JsonType`` (:issue:`60958`)
- :class:`DataFrameGroupBy` and :class:`SeriesGroupBy` methods ``sum``, ``mean``, ``median``, ``prod``, ``min``, ``max``, ``std``, ``var`` and ``sem`` now accept ``skipna`` parameter (:issue:`15675`)
- :class:`Holiday` has gained the constructor argument and field ``exclude_dates`` to exclude specific datetimes from a custom holiday calendar (:issue:`54382`)
- :class:`Holiday` constructor argument ``days_of_week`` will raise a ``ValueError`` when type is something other than ``None`` or ``tuple``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- :class:`Holiday` constructor argument ``days_of_week`` will raise a ``ValueError`` when type is something other than ``None`` or ``tuple``
- :class:`Holiday` constructor argument ``days_of_week`` will raise a ``ValueError`` when type is something other than ``None`` or ``tuple`` (:issue:`61658`)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should I specify that it's a PR since there is no original issue? Or :issue: can refer to both PRs and issues?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It applies to both issues and PRs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, thanks for clarifying!

- :class:`Rolling` and :class:`Expanding` now support ``nunique`` (:issue:`26958`)
- :class:`Rolling` and :class:`Expanding` now support aggregations ``first`` and ``last`` (:issue:`33155`)
- :func:`read_parquet` accepts ``to_pandas_kwargs`` which are forwarded to :meth:`pyarrow.Table.to_pandas` which enables passing additional keywords to customize the conversion to pandas, such as ``maps_as_pydicts`` to read the Parquet map data type as python dictionaries (:issue:`56842`)
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/tseries/holiday/test_holiday.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,3 +454,10 @@ def test_exclude_date_value_error():
Timestamp("2026-06-10"),
]
Holiday("National Ice Tea Day", month=6, day=10, exclude_dates=exclude)


def test_days_of_week_value_error():
msg = "days_of_week must be None or tuple."

with pytest.raises(ValueError, match=msg):
Holiday("World Blood Donor Day", month=6, day=14, days_of_week=[0, 1])
6 changes: 4 additions & 2 deletions pandas/tseries/holiday.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,9 @@ class from pandas.tseries.offsets, default None
end_date : datetime-like, default None
Last date the holiday is observed
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
Provide a tuple of days e.g (0,1,2,3,) for Monday through Thursday
Monday=0,..,Sunday=6
Only instances of the holiday included in days_of_week will be computed
exclude_dates : DatetimeIndex or default None
Specific dates to exclude e.g. skipping a specific year's holiday

Expand Down Expand Up @@ -258,7 +259,8 @@ class from pandas.tseries.offsets, default None
)
self.end_date = Timestamp(end_date) if end_date is not None else end_date
self.observance = observance
assert days_of_week is None or type(days_of_week) == tuple
if not (days_of_week is None or isinstance(days_of_week, tuple)):
raise ValueError("days_of_week must be None or tuple.")
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.")
Expand Down
Loading