Skip to content

Commit 18b2a22

Browse files
Merge remote-tracking branch 'upstream/main' into fix-assign-failure-when-CoW
2 parents e1f7040 + b2a6d74 commit 18b2a22

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+731
-496
lines changed

.github/workflows/unit-tests.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,6 @@ jobs:
358358
359359
- name: Run Tests
360360
uses: ./.github/actions/run-tests
361-
# TEMP allow this to fail until we fixed all test failures (related to chained assignment warnings)
362-
continue-on-error: true
363361

364362
# NOTE: this job must be kept in sync with the Pyodide build job in wheels.yml
365363
emscripten:

.github/workflows/wheels.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
- [macos-14, macosx_arm64]
102102
- [windows-2022, win_amd64]
103103
- [windows-11-arm, win_arm64]
104-
python: [["cp311", "3.11"], ["cp312", "3.12"], ["cp313", "3.13"], ["cp313t", "3.13"]]
104+
python: [["cp311", "3.11"], ["cp312", "3.12"], ["cp313", "3.13"], ["cp313t", "3.13"], ["cp314", "3.14"], ["cp314t", "3.14"]]
105105
include:
106106
# Build Pyodide wheels and upload them to Anaconda.org
107107
# NOTE: this job is similar to the one in unit-tests.yml except for the fact

doc/source/whatsnew/v2.3.3.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ become the default string dtype in pandas 3.0. See
2222

2323
Bug fixes
2424
^^^^^^^^^
25+
- Fix bug in :meth:`Series.str.replace` using named capture groups (e.g., ``\g<name>``) with the Arrow-backed dtype would raise an error (:issue:`57636`)
2526
- Fix regression in ``~Series.str.contains``, ``~Series.str.match`` and ``~Series.str.fullmatch``
2627
with a compiled regex and custom flags (:issue:`62240`)
2728

doc/source/whatsnew/v3.0.0.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ Other API changes
603603
an empty ``RangeIndex`` or empty ``Index`` with object dtype when determining
604604
the dtype of the resulting Index (:issue:`60797`)
605605
- :class:`IncompatibleFrequency` now subclasses ``TypeError`` instead of ``ValueError``. As a result, joins with mismatched frequencies now cast to object like other non-comparable joins, and arithmetic with indexes with mismatched frequencies align (:issue:`55782`)
606+
- :meth:`CategoricalIndex.append` no longer attempts to cast different-dtype indexes to the caller's dtype (:issue:`41626`)
606607
- :meth:`ExtensionDtype.construct_array_type` is now a regular method instead of a ``classmethod`` (:issue:`58663`)
607608
- Comparison operations between :class:`Index` and :class:`Series` now consistently return :class:`Series` regardless of which object is on the left or right (:issue:`36759`)
608609
- Numpy functions like ``np.isinf`` that return a bool dtype when called on a :class:`Index` object now return a bool-dtype :class:`Index` instead of ``np.ndarray`` (:issue:`52676`)
@@ -974,8 +975,8 @@ Indexing
974975
- Bug in reindexing of :class:`DataFrame` with :class:`PeriodDtype` columns in case of consolidated block (:issue:`60980`, :issue:`60273`)
975976
- Bug in :meth:`DataFrame.loc.__getitem__` and :meth:`DataFrame.iloc.__getitem__` with a :class:`CategoricalDtype` column with integer categories raising when trying to index a row containing a ``NaN`` entry (:issue:`58954`)
976977
- Bug in :meth:`Index.__getitem__` incorrectly raising with a 0-dim ``np.ndarray`` key (:issue:`55601`)
978+
- Bug in adding new rows with :meth:`DataFrame.loc.__setitem__` or :class:`Series.loc.__setitem__` which failed to retain dtype on the object's index in some cases (:issue:`41626`)
977979
- Bug in indexing on a :class:`DatetimeIndex` with a ``timestamp[pyarrow]`` dtype or on a :class:`TimedeltaIndex` with a ``duration[pyarrow]`` dtype (:issue:`62277`)
978-
-
979980

980981
Missing
981982
^^^^^^^
@@ -1083,6 +1084,7 @@ Reshaping
10831084
- Bug in :meth:`DataFrame.join` when a :class:`DataFrame` with a :class:`MultiIndex` would raise an ``AssertionError`` when :attr:`MultiIndex.names` contained ``None``. (:issue:`58721`)
10841085
- Bug in :meth:`DataFrame.merge` where merging on a column containing only ``NaN`` values resulted in an out-of-bounds array access (:issue:`59421`)
10851086
- Bug in :meth:`DataFrame.unstack` producing incorrect results when ``sort=False`` (:issue:`54987`, :issue:`55516`)
1087+
- Bug in :meth:`DataFrame.unstack` raising an error with indexes containing ``NaN`` with ``sort=False`` (:issue:`61221`)
10861088
- Bug in :meth:`DataFrame.merge` when merging two :class:`DataFrame` on ``intc`` or ``uintc`` types on Windows (:issue:`60091`, :issue:`58713`)
10871089
- Bug in :meth:`DataFrame.pivot_table` incorrectly subaggregating results when called without an ``index`` argument (:issue:`58722`)
10881090
- Bug in :meth:`DataFrame.pivot_table` incorrectly ignoring the ``values`` argument when also supplied to the ``index`` or ``columns`` parameters (:issue:`57876`, :issue:`61292`)
@@ -1093,7 +1095,7 @@ Reshaping
10931095
- Bug in :func:`melt` where calling with duplicate column names in ``id_vars`` raised a misleading ``AttributeError`` (:issue:`61475`)
10941096
- Bug in :meth:`DataFrame.merge` where user-provided suffixes could result in duplicate column names if the resulting names matched existing columns. Now raises a :class:`MergeError` in such cases. (:issue:`61402`)
10951097
- Bug in :meth:`DataFrame.merge` with :class:`CategoricalDtype` columns incorrectly raising ``RecursionError`` (:issue:`56376`)
1096-
-
1098+
- Bug in :meth:`DataFrame.merge` with a ``float32`` index incorrectly casting the index to ``float64`` (:issue:`41626`)
10971099

10981100
Sparse
10991101
^^^^^^
@@ -1158,6 +1160,7 @@ Other
11581160
- Bug in printing a :class:`DataFrame` with a :class:`DataFrame` stored in :attr:`DataFrame.attrs` raised a ``ValueError`` (:issue:`60455`)
11591161
- Bug in printing a :class:`Series` with a :class:`DataFrame` stored in :attr:`Series.attrs` raised a ``ValueError`` (:issue:`60568`)
11601162
- Deprecated the keyword ``check_datetimelike_compat`` in :meth:`testing.assert_frame_equal` and :meth:`testing.assert_series_equal` (:issue:`55638`)
1163+
- Fixed bug in the :meth:`Series.rank` with object dtype and extremely small float values (:issue:`62036`)
11611164
- Fixed bug where the :class:`DataFrame` constructor misclassified array-like objects with a ``.name`` attribute as :class:`Series` or :class:`Index` (:issue:`61443`)
11621165
- Fixed regression in :meth:`DataFrame.from_records` not initializing subclasses properly (:issue:`57008`)
11631166
-

environment.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ dependencies:
9191
- sphinx
9292
- sphinx-design
9393
- sphinx-copybutton
94+
95+
# static typing
96+
- scipy-stubs
9497
- types-python-dateutil
9598
- types-PyMySQL
9699
- types-pytz

pandas/_libs/algos.pyx

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
cimport cython
22
from cython cimport Py_ssize_t
33
from libc.math cimport (
4-
fabs,
54
sqrt,
65
)
76
from libc.stdlib cimport (
@@ -72,13 +71,6 @@ tiebreakers = {
7271
}
7372

7473

75-
cdef bint are_diff(object left, object right):
76-
try:
77-
return fabs(left - right) > FP_ERR
78-
except TypeError:
79-
return left != right
80-
81-
8274
class Infinity:
8375
"""
8476
Provide a positive Infinity comparison method for ranking.
@@ -1135,12 +1127,8 @@ cdef void rank_sorted_1d(
11351127
dups += 1
11361128
sum_ranks += i - grp_start + 1
11371129

1138-
if numeric_object_t is object:
1139-
next_val_diff = at_end or are_diff(masked_vals[sort_indexer[i]],
1140-
masked_vals[sort_indexer[i+1]])
1141-
else:
1142-
next_val_diff = at_end or (masked_vals[sort_indexer[i]]
1143-
!= masked_vals[sort_indexer[i+1]])
1130+
next_val_diff = at_end or (masked_vals[sort_indexer[i]]
1131+
!= masked_vals[sort_indexer[i+1]])
11441132

11451133
# We'll need this check later anyway to determine group size, so just
11461134
# compute it here since shortcircuiting won't help

pandas/_testing/asserters.py

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -584,19 +584,13 @@ def raise_assert_detail(
584584

585585
if isinstance(left, np.ndarray):
586586
left = pprint_thing(left)
587-
elif isinstance(left, (CategoricalDtype, NumpyEADtype)):
587+
elif isinstance(left, (CategoricalDtype, StringDtype, NumpyEADtype)):
588588
left = repr(left)
589-
elif isinstance(left, StringDtype):
590-
# TODO(infer_string) this special case could be avoided if we have
591-
# a more informative repr https://github.com/pandas-dev/pandas/issues/59342
592-
left = f"StringDtype(storage={left.storage}, na_value={left.na_value})"
593589

594590
if isinstance(right, np.ndarray):
595591
right = pprint_thing(right)
596-
elif isinstance(right, (CategoricalDtype, NumpyEADtype)):
592+
elif isinstance(right, (CategoricalDtype, StringDtype, NumpyEADtype)):
597593
right = repr(right)
598-
elif isinstance(right, StringDtype):
599-
right = f"StringDtype(storage={right.storage}, na_value={right.na_value})"
600594

601595
msg += f"""
602596
[left]: {left}

pandas/_testing/contexts.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
)
1313
import uuid
1414

15-
from pandas.compat import PYPY
15+
from pandas.compat import (
16+
PYPY,
17+
WARNING_CHECK_DISABLED,
18+
)
1619
from pandas.errors import ChainedAssignmentError
1720

1821
from pandas.io.common import get_handle
@@ -163,7 +166,7 @@ def with_csv_dialect(name: str, **kwargs) -> Generator[None]:
163166
def raises_chained_assignment_error(extra_warnings=(), extra_match=()):
164167
from pandas._testing import assert_produces_warning
165168

166-
if PYPY:
169+
if PYPY or WARNING_CHECK_DISABLED:
167170
if not extra_warnings:
168171
from contextlib import nullcontext
169172

pandas/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ def render(pieces, style):
640640
}
641641

642642

643-
def get_versions():
643+
def get_versions() -> dict:
644644
"""Get version information or return default if unable to do so."""
645645
# I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
646646
# __file__, we can work backwards from there to the root. Some

pandas/compat/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
PY312,
2222
PY314,
2323
PYPY,
24+
WARNING_CHECK_DISABLED,
2425
WASM,
2526
)
2627
from pandas.compat.numpy import is_numpy_dev
@@ -158,6 +159,7 @@ def is_ci_environment() -> bool:
158159
"PY314",
159160
"PYARROW_MIN_VERSION",
160161
"PYPY",
162+
"WARNING_CHECK_DISABLED",
161163
"WASM",
162164
"is_numpy_dev",
163165
"pa_version_under14p0",

0 commit comments

Comments
 (0)