Skip to content

Commit 7fdbbf1

Browse files
harupyclaude
andcommitted
BUG: Fix NotImplementedError when comparing ArrowExtensionArray to range
🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 2d6c51f commit 7fdbbf1

3 files changed

Lines changed: 10 additions & 2 deletions

File tree

pandas/core/arrays/arrow/array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ def _cmp_method(self, other, op) -> ArrowExtensionArray:
905905
pc_func = ARROW_CMP_FUNCS[op.__name__]
906906
ltype = self._pa_array.type
907907

908-
if isinstance(other, (ExtensionArray, np.ndarray, list)):
908+
if isinstance(other, (ExtensionArray, np.ndarray, list, range)):
909909
try:
910910
boxed = self._box_pa(other)
911911
except pa.lib.ArrowInvalid:

pandas/core/ops/invalid.py

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

2626
def invalid_comparison(
2727
left: ArrayLike,
28-
right: ArrayLike | list | Scalar,
28+
right: ArrayLike | list | range | Scalar,
2929
op: Callable[[Any, Any], bool],
3030
) -> npt.NDArray[np.bool_]:
3131
"""

pandas/tests/extension/test_arrow.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3817,3 +3817,11 @@ def test_ufunc_retains_missing():
38173817

38183818
expected = pd.Series([np.sin(0.1), pd.NA], dtype="float64[pyarrow]")
38193819
tm.assert_series_equal(result, expected)
3820+
3821+
3822+
def test_comparison_with_range():
3823+
# GH#63429
3824+
df = pd.DataFrame({"a": [0, 1], "b": [2, 3]})
3825+
result = df.columns == range(len(df.columns))
3826+
expected = np.array([False, False])
3827+
tm.assert_numpy_array_equal(result, expected)

0 commit comments

Comments
 (0)