Skip to content

Commit 58b182b

Browse files
Backport PR #57341 on branch 2.2.x (REGR: assert_series_equal defaulting to check_exact=True for Index) (#57380)
Backport PR #57341: REGR: assert_series_equal defaulting to check_exact=True for Index Co-authored-by: Patrick Hoefler <[email protected]>
1 parent 947f5ae commit 58b182b

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

doc/source/whatsnew/v2.2.1.rst

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Fixed regressions
1717
- Fixed performance regression in :meth:`Series.combine_first` (:issue:`55845`)
1818
- Fixed regression in :func:`concat` changing long-standing behavior that always sorted the non-concatenation axis when the axis was a :class:`DatetimeIndex` (:issue:`57006`)
1919
- Fixed regression in :func:`merge_ordered` raising ``TypeError`` for ``fill_method="ffill"`` and ``how="left"`` (:issue:`57010`)
20+
- Fixed regression in :func:`pandas.testing.assert_series_equal` defaulting to ``check_exact=True`` when checking the :class:`Index` (:issue:`57067`)
2021
- Fixed regression in :func:`wide_to_long` raising an ``AttributeError`` for string columns (:issue:`57066`)
2122
- Fixed regression in :meth:`.DataFrameGroupBy.idxmin`, :meth:`.DataFrameGroupBy.idxmax`, :meth:`.SeriesGroupBy.idxmin`, :meth:`.SeriesGroupBy.idxmax` ignoring the ``skipna`` argument (:issue:`57040`)
2223
- Fixed regression in :meth:`.DataFrameGroupBy.idxmin`, :meth:`.DataFrameGroupBy.idxmax`, :meth:`.SeriesGroupBy.idxmin`, :meth:`.SeriesGroupBy.idxmax` where values containing the minimum or maximum value for the dtype could produce incorrect results (:issue:`57040`)

pandas/_testing/asserters.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,7 @@ def assert_series_equal(
902902
>>> tm.assert_series_equal(a, b)
903903
"""
904904
__tracebackhide__ = True
905+
check_exact_index = False if check_exact is lib.no_default else check_exact
905906
if (
906907
check_exact is lib.no_default
907908
and rtol is lib.no_default
@@ -944,7 +945,7 @@ def assert_series_equal(
944945
right.index,
945946
exact=check_index_type,
946947
check_names=check_names,
947-
check_exact=check_exact,
948+
check_exact=check_exact_index,
948949
check_categorical=check_categorical,
949950
check_order=not check_like,
950951
rtol=rtol,

pandas/tests/util/test_assert_series_equal.py

+8
Original file line numberDiff line numberDiff line change
@@ -474,3 +474,11 @@ def test_assert_series_equal_int_tol():
474474
tm.assert_extension_array_equal(
475475
left.astype("Int64").values, right.astype("Int64").values, rtol=1.5
476476
)
477+
478+
479+
def test_assert_series_equal_index_exact_default():
480+
# GH#57067
481+
ser1 = Series(np.zeros(6, dtype=int), [0, 0.2, 0.4, 0.6, 0.8, 1])
482+
ser2 = Series(np.zeros(6, dtype=int), np.linspace(0, 1, 6))
483+
tm.assert_series_equal(ser1, ser2)
484+
tm.assert_frame_equal(ser1.to_frame(), ser2.to_frame())

0 commit comments

Comments
 (0)