Skip to content

Commit 10b26fe

Browse files
authored
Backport PR #57333 on branch 2.2.x (REGR: merge with 3rd party EA's can sometimes raise ValueError) (#57337)
Backport PR #57333: REGR: merge with 3rd party EA's can sometimes raise ValueError
1 parent 28a7ec7 commit 10b26fe

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

doc/source/whatsnew/v2.2.1.rst

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Fixed regressions
2222
- 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`)
2323
- Fixed regression in :meth:`CategoricalIndex.difference` raising ``KeyError`` when other contains null values other than NaN (:issue:`57318`)
2424
- Fixed regression in :meth:`DataFrame.loc` raising ``IndexError`` for non-unique, masked dtype indexes where result has more than 10,000 rows (:issue:`57027`)
25+
- Fixed regression in :meth:`DataFrame.merge` raising ``ValueError`` for certain types of 3rd-party extension arrays (:issue:`57316`)
2526
- Fixed regression in :meth:`DataFrame.sort_index` not producing a stable sort for a index with duplicates (:issue:`57151`)
2627
- Fixed regression in :meth:`DataFrame.to_dict` with ``orient='list'`` and datetime or timedelta types returning integers (:issue:`54824`)
2728
- Fixed regression in :meth:`DataFrame.to_json` converting nullable integers to floats (:issue:`57224`)

pandas/_libs/index.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ cdef class IndexEngine:
295295
values = self.values
296296
self.monotonic_inc, self.monotonic_dec, is_strict_monotonic = \
297297
self._call_monotonic(values)
298-
except TypeError:
298+
except (TypeError, ValueError):
299299
self.monotonic_inc = 0
300300
self.monotonic_dec = 0
301301
is_strict_monotonic = 0

pandas/tests/indexes/test_base.py

+10
Original file line numberDiff line numberDiff line change
@@ -1722,3 +1722,13 @@ def test_nan_comparison_same_object(op):
17221722

17231723
result = op(idx, idx.copy())
17241724
tm.assert_numpy_array_equal(result, expected)
1725+
1726+
1727+
@td.skip_if_no("pyarrow")
1728+
def test_is_monotonic_pyarrow_list_type():
1729+
# GH 57333
1730+
import pyarrow as pa
1731+
1732+
idx = Index([[1], [2, 3]], dtype=pd.ArrowDtype(pa.list_(pa.int64())))
1733+
assert not idx.is_monotonic_increasing
1734+
assert not idx.is_monotonic_decreasing

0 commit comments

Comments
 (0)