Skip to content

Commit 238321a

Browse files
authored
Merge branch 'main' into BUG-#61583,to_stata
2 parents 0ca0c9e + 8a1d5a0 commit 238321a

32 files changed

+788
-629
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
-----------------
77

8-
# pandas: powerful Python data analysis toolkit
8+
# pandas: A Powerful Python Data Analysis Toolkit
99

1010
| | |
1111
| --- | --- |

ci/deps/actions-310-minimum_versions.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ dependencies:
1818
- pytest-xdist>=3.4.0
1919
- pytest-localserver>=0.8.1
2020
- pytest-qt>=4.4.0
21-
- boto3
21+
- boto3=1.37.3
2222

2323
# required dependencies
2424
- python-dateutil=2.8.2

ci/deps/actions-310.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies:
1616
- pytest-xdist>=3.4.0
1717
- pytest-localserver>=0.8.1
1818
- pytest-qt>=4.4.0
19-
- boto3
19+
- boto3=1.37.3
2020

2121
# required dependencies
2222
- python-dateutil

ci/deps/actions-311-downstream_compat.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies:
1717
- pytest-xdist>=3.4.0
1818
- pytest-localserver>=0.8.1
1919
- pytest-qt>=4.4.0
20-
- boto3
20+
- boto3=1.37.3
2121

2222
# required dependencies
2323
- python-dateutil

ci/deps/actions-311.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies:
1616
- pytest-xdist>=3.4.0
1717
- pytest-localserver>=0.8.1
1818
- pytest-qt>=4.4.0
19-
- boto3
19+
- boto3=1.37.3
2020

2121
# required dependencies
2222
- python-dateutil

ci/deps/actions-312.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies:
1616
- pytest-xdist>=3.4.0
1717
- pytest-localserver>=0.8.1
1818
- pytest-qt>=4.4.0
19-
- boto3
19+
- boto3=1.37.3
2020

2121
# required dependencies
2222
- python-dateutil

ci/deps/actions-313.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ dependencies:
1616
- pytest-xdist>=3.4.0
1717
- pytest-localserver>=0.8.1
1818
- pytest-qt>=4.4.0
19-
- boto3
19+
- boto3=1.37.3
2020

2121
# required dependencies
2222
- python-dateutil

doc/source/development/community.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ Any community member can open issues to:
7777
- Ask questions, e.g. "I noticed the behavior of a certain function
7878
changed between versions. Is this expected?".
7979

80-
Ideally, your questions should be related to how pandas works rather
80+
- Ideally, your questions should be related to how pandas works rather
8181
than how you use pandas. `StackOverflow <https://stackoverflow.com/>`_ is
8282
better suited for answering usage questions, and we ask that all usage
8383
questions are first asked on StackOverflow. Thank you for respecting our

doc/source/development/contributing.rst

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,14 @@ and merged into project to appear the in the next release. To submit a pull requ
234234
#. Write a descriptive title that includes prefixes. pandas uses a convention for title
235235
prefixes. Here are some common ones along with general guidelines for when to use them:
236236

237-
* ENH: Enhancement, new functionality
238-
* BUG: Bug fix
239-
* DOC: Additions/updates to documentation
240-
* TST: Additions/updates to tests
241-
* BLD: Updates to the build process/scripts
242-
* PERF: Performance improvement
243-
* TYP: Type annotations
244-
* CLN: Code cleanup
237+
* ENH: Enhancement, new functionality
238+
* BUG: Bug fix
239+
* DOC: Additions/updates to documentation
240+
* TST: Additions/updates to tests
241+
* BLD: Updates to the build process/scripts
242+
* PERF: Performance improvement
243+
* TYP: Type annotations
244+
* CLN: Code cleanup
245245

246246
#. Write a description of your changes in the ``Preview Discussion`` tab
247247
#. Click ``Send Pull Request``.

doc/source/development/contributing_codebase.rst

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,11 +444,11 @@ be located.
444444
result = ser.loc[[3, 4]]
445445
tm.assert_series_equal(result, expected)
446446
447-
In cases like this, the test location should be based on the *underlying*
448-
method being tested. Or in the case of a test for a bugfix, the location
449-
of the actual bug. So in this example, we know that ``Series.__getitem__``
450-
calls ``Series.loc.__getitem__``, so this is *really* a test for
451-
``loc.__getitem__``. So this test belongs in ``tests.indexing.test_loc``.
447+
In cases like this, the test location should be based on the *underlying*
448+
method being tested. Or in the case of a test for a bugfix, the location
449+
of the actual bug. So in this example, we know that ``Series.__getitem__``
450+
calls ``Series.loc.__getitem__``, so this is *really* a test for
451+
``loc.__getitem__``. So this test belongs in ``tests.indexing.test_loc``.
452452

453453
6. Is your test for a DataFrame or Series method?
454454

doc/source/development/contributing_gitpod.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ Option 1: using Liveserve
158158
file and click on **Open with Live Serve**. Alternatively, you can open the
159159
file in the editor and click on the **Go live** button on the status bar.
160160

161-
.. image:: ./gitpod-imgs/vscode-statusbar.png
162-
:alt: Gitpod workspace VSCode start live serve screenshot
161+
.. image:: ./gitpod-imgs/vscode-statusbar.png
162+
:alt: Gitpod workspace VSCode start live serve screenshot
163163

164164
#. A simple browser will open to the right-hand side of the editor. We recommend
165165
closing it and click on the **Open in browser** button in the pop-up.
@@ -182,13 +182,13 @@ uses the rst extension with docutils.
182182
:kbd:`Ctrl-Shift-P` in Linux and Windows. Start typing "restructured"
183183
and choose either "Open preview" or "Open preview to the Side".
184184

185-
.. image:: ./gitpod-imgs/vscode-rst.png
186-
:alt: Gitpod workspace VSCode open rst screenshot
185+
.. image:: ./gitpod-imgs/vscode-rst.png
186+
:alt: Gitpod workspace VSCode open rst screenshot
187187

188188
#. As you work on the document, you will see a live rendering of it on the editor.
189189

190-
.. image:: ./gitpod-imgs/rst-rendering.png
191-
:alt: Gitpod workspace VSCode rst rendering screenshot
190+
.. image:: ./gitpod-imgs/rst-rendering.png
191+
:alt: Gitpod workspace VSCode rst rendering screenshot
192192

193193
If you want to see the final output with the ``html`` theme you will need to
194194
rebuild the docs with ``make html`` and use Live Serve as described in option 1.

doc/source/development/debugging_extensions.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ pandas uses Cython and C/C++ `extension modules <https://docs.python.org/3/exten
1010

1111
For Python developers with limited or no C/C++ experience this can seem a daunting task. Core developer Will Ayd has written a 3 part blog series to help guide you from the standard Python debugger into these other tools:
1212

13-
1. `Fundamental Python Debugging Part 1 - Python <https://willayd.com/fundamental-python-debugging-part-1-python.html>`_
14-
2. `Fundamental Python Debugging Part 2 - Python Extensions <https://willayd.com/fundamental-python-debugging-part-2-python-extensions.html>`_
15-
3. `Fundamental Python Debugging Part 3 - Cython Extensions <https://willayd.com/fundamental-python-debugging-part-3-cython-extensions.html>`_
13+
1. `Fundamental Python Debugging Part 1 - Python <https://willayd.com/fundamental-python-debugging-part-1-python.html>`_
14+
2. `Fundamental Python Debugging Part 2 - Python Extensions <https://willayd.com/fundamental-python-debugging-part-2-python-extensions.html>`_
15+
3. `Fundamental Python Debugging Part 3 - Cython Extensions <https://willayd.com/fundamental-python-debugging-part-3-cython-extensions.html>`_
1616

1717
Debugging locally
1818
-----------------

doc/source/development/developer.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -116,19 +116,19 @@ The ``metadata`` field is ``None`` except for:
116116
omitted it is assumed to be nanoseconds.
117117
* ``categorical``: ``{'num_categories': K, 'ordered': is_ordered, 'type': $TYPE}``
118118

119-
* Here ``'type'`` is optional, and can be a nested pandas type specification
120-
here (but not categorical)
119+
* Here ``'type'`` is optional, and can be a nested pandas type specification
120+
here (but not categorical)
121121

122122
* ``unicode``: ``{'encoding': encoding}``
123123

124-
* The encoding is optional, and if not present is UTF-8
124+
* The encoding is optional, and if not present is UTF-8
125125

126126
* ``object``: ``{'encoding': encoding}``. Objects can be serialized and stored
127127
in ``BYTE_ARRAY`` Parquet columns. The encoding can be one of:
128128

129-
* ``'pickle'``
130-
* ``'bson'``
131-
* ``'json'``
129+
* ``'pickle'``
130+
* ``'bson'``
131+
* ``'json'``
132132

133133
* ``timedelta``: ``{'unit': 'ns'}``. The ``'unit'`` is optional, and if omitted
134134
it is assumed to be nanoseconds. This metadata is optional altogether

doc/source/development/maintaining.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,11 @@ pandas supports point releases (e.g. ``1.4.3``) that aim to:
218218

219219
1. Fix bugs in new features introduced in the first minor version release.
220220

221-
* e.g. If a new feature was added in ``1.4`` and contains a bug, a fix can be applied in ``1.4.3``
221+
* e.g. If a new feature was added in ``1.4`` and contains a bug, a fix can be applied in ``1.4.3``
222222

223223
2. Fix bugs that used to work in a few minor releases prior. There should be agreement between core team members that a backport is appropriate.
224224

225-
* e.g. If a feature worked in ``1.2`` and stopped working since ``1.3``, a fix can be applied in ``1.4.3``.
225+
* e.g. If a feature worked in ``1.2`` and stopped working since ``1.3``, a fix can be applied in ``1.4.3``.
226226

227227
Since pandas minor releases are based on GitHub branches (e.g. point release of ``1.4`` are based off the ``1.4.x`` branch),
228228
"backporting" means merging a pull request fix to the ``main`` branch and correct minor branch associated with the next point release.
@@ -289,8 +289,8 @@ The required steps for adding a maintainer are:
289289
1. Contact the contributor and ask their interest to join.
290290
2. Add the contributor to the appropriate `GitHub Team <https://github.com/orgs/pandas-dev/teams>`_ if accepted the invitation.
291291

292-
* ``pandas-core`` is for core team members
293-
* ``pandas-triage`` is for pandas triage members
292+
* ``pandas-core`` is for core team members
293+
* ``pandas-triage`` is for pandas triage members
294294

295295
If adding to ``pandas-core``, there are two additional steps:
296296

@@ -467,10 +467,10 @@ Post-Release
467467
patch releases. The exact instructions are (replace the example version numbers by
468468
the appropriate ones for the version you are releasing):
469469

470-
- Log in to the server and use the correct user.
471-
- ``cd /var/www/html/pandas-docs/``
472-
- ``ln -sfn version/2.1 stable`` (for a major or minor release)
473-
- ``ln -sfn version/2.0.3 version/2.0`` (for a patch release)
470+
- Log in to the server and use the correct user.
471+
- ``cd /var/www/html/pandas-docs/``
472+
- ``ln -sfn version/2.1 stable`` (for a major or minor release)
473+
- ``ln -sfn version/2.0.3 version/2.0`` (for a patch release)
474474

475475
2. If releasing a major or minor release, open a PR in our source code to update
476476
``web/pandas/versions.json``, to have the desired versions in the documentation
@@ -487,8 +487,8 @@ Post-Release
487487
6. Announce the new release in the official channels (use previous announcements
488488
for reference):
489489

490-
- The pandas-dev and pydata mailing lists
491-
- X, Mastodon, Telegram and LinkedIn
490+
- The pandas-dev and pydata mailing lists
491+
- X, Mastodon, Telegram and LinkedIn
492492

493493
7. Update this release instructions to fix anything incorrect and to update about any
494494
change since the last release.

doc/source/whatsnew/v3.0.0.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ Other enhancements
6464
- :meth:`Series.nlargest` uses a 'stable' sort internally and will preserve original ordering.
6565
- :class:`ArrowDtype` now supports ``pyarrow.JsonType`` (:issue:`60958`)
6666
- :class:`DataFrameGroupBy` and :class:`SeriesGroupBy` methods ``sum``, ``mean``, ``median``, ``prod``, ``min``, ``max``, ``std``, ``var`` and ``sem`` now accept ``skipna`` parameter (:issue:`15675`)
67+
- :class:`Easter` has gained a new constructor argument ``method`` which specifies the method used to calculate Easter — for example, Orthodox Easter (:issue:`61665`)
68+
- :class:`Holiday` constructor argument ``days_of_week`` will raise a ``ValueError`` when type is something other than ``None`` or ``tuple`` (:issue:`61658`)
69+
- :class:`Holiday` has gained the constructor argument and field ``exclude_dates`` to exclude specific datetimes from a custom holiday calendar (:issue:`54382`)
6770
- :class:`Rolling` and :class:`Expanding` now support ``nunique`` (:issue:`26958`)
6871
- :class:`Rolling` and :class:`Expanding` now support aggregations ``first`` and ``last`` (:issue:`33155`)
6972
- :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`)
@@ -715,6 +718,7 @@ Numeric
715718
- Bug in :meth:`DataFrame.cov` raises a ``TypeError`` instead of returning potentially incorrect results or other errors (:issue:`53115`)
716719
- Bug in :meth:`DataFrame.quantile` where the column type was not preserved when ``numeric_only=True`` with a list-like ``q`` produced an empty result (:issue:`59035`)
717720
- Bug in :meth:`Series.dot` returning ``object`` dtype for :class:`ArrowDtype` and nullable-dtype data (:issue:`61375`)
721+
- Bug in :meth:`Series.std` and :meth:`Series.var` when using complex-valued data (:issue:`61645`)
718722
- Bug in ``np.matmul`` with :class:`Index` inputs raising a ``TypeError`` (:issue:`57079`)
719723

720724
Conversion
@@ -885,6 +889,7 @@ Other
885889
- Bug in :func:`eval` with ``engine="numexpr"`` returning unexpected result for float division. (:issue:`59736`)
886890
- Bug in :func:`to_numeric` raising ``TypeError`` when ``arg`` is a :class:`Timedelta` or :class:`Timestamp` scalar. (:issue:`59944`)
887891
- Bug in :func:`unique` on :class:`Index` not always returning :class:`Index` (:issue:`57043`)
892+
- Bug in :meth:`DataFrame.apply` raising ``RecursionError`` when passing ``func=list[int]``. (:issue:`61565`)
888893
- Bug in :meth:`DataFrame.apply` where passing ``engine="numba"`` ignored ``args`` passed to the applied function (:issue:`58712`)
889894
- Bug in :meth:`DataFrame.eval` and :meth:`DataFrame.query` which caused an exception when using NumPy attributes via ``@`` notation, e.g., ``df.eval("@np.floor(a)")``. (:issue:`58041`)
890895
- Bug in :meth:`DataFrame.eval` and :meth:`DataFrame.query` which did not allow to use ``tan`` function. (:issue:`55091`)

pandas/_libs/lib.pyx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ from collections import abc
22
from decimal import Decimal
33
from enum import Enum
44
from sys import getsizeof
5+
from types import GenericAlias
56
from typing import (
67
Literal,
78
_GenericAlias,
@@ -1298,7 +1299,7 @@ cdef bint c_is_list_like(object obj, bint allow_sets) except -1:
12981299
getattr(obj, "__iter__", None) is not None and not isinstance(obj, type)
12991300
# we do not count strings/unicode/bytes as list-like
13001301
# exclude Generic types that have __iter__
1301-
and not isinstance(obj, (str, bytes, _GenericAlias))
1302+
and not isinstance(obj, (str, bytes, _GenericAlias, GenericAlias))
13021303
# exclude zero-dimensional duck-arrays, effectively scalars
13031304
and not (hasattr(obj, "ndim") and obj.ndim == 0)
13041305
# exclude sets if allow_sets is False

pandas/_libs/tslibs/offsets.pyi

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,13 @@ class FY5253Quarter(FY5253Mixin):
230230
variation: Literal["nearest", "last"] = ...,
231231
) -> None: ...
232232

233-
class Easter(SingleConstructorOffset): ...
233+
class Easter(SingleConstructorOffset):
234+
def __init__(
235+
self,
236+
n: int = ...,
237+
normalize: bool = ...,
238+
method: int = ...,
239+
) -> None: ...
234240

235241
class _CustomBusinessMonth(BusinessMixin):
236242
def __init__(

pandas/_libs/tslibs/offsets.pyx

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4520,6 +4520,12 @@ cdef class Easter(SingleConstructorOffset):
45204520
The number of years represented.
45214521
normalize : bool, default False
45224522
Normalize start/end dates to midnight before generating date range.
4523+
method : int, default 3
4524+
The method used to calculate the date of Easter. Valid options are:
4525+
- 1 (EASTER_JULIAN): Original calculation in Julian calendar
4526+
- 2 (EASTER_ORTHODOX): Original method, date converted to Gregorian calendar
4527+
- 3 (EASTER_WESTERN): Revised method, in Gregorian calendar
4528+
These constants are defined in the `dateutil.easter` module.
45234529
45244530
See Also
45254531
--------
@@ -4532,15 +4538,32 @@ cdef class Easter(SingleConstructorOffset):
45324538
Timestamp('2022-04-17 00:00:00')
45334539
"""
45344540

4541+
_attributes = tuple(["n", "normalize", "method"])
4542+
4543+
cdef readonly:
4544+
int method
4545+
4546+
from dateutil.easter import EASTER_WESTERN
4547+
4548+
def __init__(self, n=1, normalize=False, method=EASTER_WESTERN):
4549+
BaseOffset.__init__(self, n, normalize)
4550+
4551+
self.method = method
4552+
4553+
if method < 1 or method > 3:
4554+
raise ValueError(f"Method must be 1<=method<=3, got {method}")
4555+
45354556
cpdef __setstate__(self, state):
4557+
from dateutil.easter import EASTER_WESTERN
45364558
self.n = state.pop("n")
45374559
self.normalize = state.pop("normalize")
4560+
self.method = state.pop("method", EASTER_WESTERN)
45384561

45394562
@apply_wraps
45404563
def _apply(self, other: datetime) -> datetime:
45414564
from dateutil.easter import easter
45424565

4543-
current_easter = easter(other.year)
4566+
current_easter = easter(other.year, method=self.method)
45444567
current_easter = datetime(
45454568
current_easter.year, current_easter.month, current_easter.day
45464569
)
@@ -4555,7 +4578,7 @@ cdef class Easter(SingleConstructorOffset):
45554578

45564579
# NOTE: easter returns a datetime.date so we have to convert to type of
45574580
# other
4558-
new = easter(other.year + n)
4581+
new = easter(other.year + n, method=self.method)
45594582
new = datetime(
45604583
new.year,
45614584
new.month,
@@ -4573,7 +4596,7 @@ cdef class Easter(SingleConstructorOffset):
45734596

45744597
from dateutil.easter import easter
45754598

4576-
return date(dt.year, dt.month, dt.day) == easter(dt.year)
4599+
return date(dt.year, dt.month, dt.day) == easter(dt.year, method=self.method)
45774600

45784601

45794602
# ----------------------------------------------------------------------

pandas/core/nanops.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,11 @@ def nanvar(
10141014
avg = _ensure_numeric(values.sum(axis=axis, dtype=np.float64)) / count
10151015
if axis is not None:
10161016
avg = np.expand_dims(avg, axis)
1017-
sqr = _ensure_numeric((avg - values) ** 2)
1017+
if values.dtype.kind == "c":
1018+
# Need to use absolute value for complex numbers.
1019+
sqr = _ensure_numeric(abs(avg - values) ** 2)
1020+
else:
1021+
sqr = _ensure_numeric((avg - values) ** 2)
10181022
if mask is not None:
10191023
np.putmask(sqr, mask, 0)
10201024
result = sqr.sum(axis=axis, dtype=np.float64) / d

pandas/tests/dtypes/test_inference.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,15 @@ class MyDataFrame(DataFrame, Generic[T]): ...
250250
assert inference.is_list_like(tst)
251251

252252

253+
def test_is_list_like_native_container_types():
254+
# GH 61565
255+
# is_list_like was yielding false positives for native container types
256+
assert not inference.is_list_like(list[int])
257+
assert not inference.is_list_like(list[str])
258+
assert not inference.is_list_like(tuple[int])
259+
assert not inference.is_list_like(tuple[str])
260+
261+
253262
def test_is_sequence():
254263
is_seq = inference.is_sequence
255264
assert is_seq((1, 2))

pandas/tests/extension/base/setitem.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -440,11 +440,11 @@ def test_delitem_series(self, data):
440440
tm.assert_series_equal(ser, expected)
441441

442442
def test_setitem_invalid(self, data, invalid_scalar):
443-
msg = "" # messages vary by subclass, so we do not test it
444-
with pytest.raises((ValueError, TypeError), match=msg):
443+
# messages vary by subclass, so we do not test it
444+
with pytest.raises((ValueError, TypeError), match=None):
445445
data[0] = invalid_scalar
446446

447-
with pytest.raises((ValueError, TypeError), match=msg):
447+
with pytest.raises((ValueError, TypeError), match=None):
448448
data[:] = invalid_scalar
449449

450450
def test_setitem_2d_values(self, data):

0 commit comments

Comments
 (0)