Skip to content

BUG: NotImplementedError: eq not implemented for <class 'range'> when comparing columns and range in pandas 3.0.0rc0 #63429

@harupy

Description

@harupy

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

I'm not sure if this is really a bug.

% uv run --python=3.11 --no-project --with 'pandas==3.0.0rc0' --with pyarrow python -c '
import pandas as pd

df = pd.DataFrame({"a": [0, 1], "b": [2, 3]})

print(df.columns == range(len(df.columns)))
'

Issue Description

Traceback (most recent call last):
  File "/Users/harutaka.kawamura/Desktop/repositories/mlflow/foo/a.py", line 7, in <module>
    print(df.columns == range(len(df.columns)))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/harutaka.kawamura/.cache/uv/archive-v0/Gd1lfpovo-nwuQAEfDra9/lib/python3.11/site-packages/pandas/core/ops/common.py", line 85, in new_method
    return method(self, other)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/harutaka.kawamura/.cache/uv/archive-v0/Gd1lfpovo-nwuQAEfDra9/lib/python3.11/site-packages/pandas/core/arraylike.py", line 41, in __eq__
    return self._cmp_method(other, operator.eq)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/harutaka.kawamura/.cache/uv/archive-v0/Gd1lfpovo-nwuQAEfDra9/lib/python3.11/site-packages/pandas/core/indexes/base.py", line 7288, in _cmp_method
    result = ops.comparison_op(self._values, other, op)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/harutaka.kawamura/.cache/uv/archive-v0/Gd1lfpovo-nwuQAEfDra9/lib/python3.11/site-packages/pandas/core/ops/array_ops.py", line 337, in comparison_op
    res_values = op(lvalues, rvalues)
                 ^^^^^^^^^^^^^^^^^^^^
  File "/Users/harutaka.kawamura/.cache/uv/archive-v0/Gd1lfpovo-nwuQAEfDra9/lib/python3.11/site-packages/pandas/core/ops/common.py", line 85, in new_method
    return method(self, other)
           ^^^^^^^^^^^^^^^^^^^
  File "/Users/harutaka.kawamura/.cache/uv/archive-v0/Gd1lfpovo-nwuQAEfDra9/lib/python3.11/site-packages/pandas/core/arraylike.py", line 41, in __eq__
    return self._cmp_method(other, operator.eq)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/harutaka.kawamura/.cache/uv/archive-v0/Gd1lfpovo-nwuQAEfDra9/lib/python3.11/site-packages/pandas/core/arrays/string_arrow.py", line 535, in _cmp_method
    result = super()._cmp_method(other, op)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/harutaka.kawamura/.cache/uv/archive-v0/Gd1lfpovo-nwuQAEfDra9/lib/python3.11/site-packages/pandas/core/arrays/arrow/array.py", line 950, in _cmp_method
    raise NotImplementedError(
NotImplementedError: eq not implemented for <class 'range'>

Expected Behavior

No error

Installed Versions

Details
INSTALLED VERSIONS
------------------
commit                : 1a3230dc5be4c87b8356765ea3b6568d37cb82fd
python                : 3.11.9
python-bits           : 64
OS                    : Darwin
OS-release            : 24.6.0
Version               : Darwin Kernel Version 24.6.0: Mon Aug 11 21:16:34 PDT 2025; root:xnu-11417.140.69.701.11~1/RELEASE_ARM64_T6020
machine               : arm64
processor             : arm
byteorder             : little
LC_ALL                : None
LANG                  : ja_JP.UTF-8
LOCALE                : ja_JP.UTF-8

pandas                : 3.0.0rc0
numpy                 : 2.3.5
dateutil              : 2.9.0.post0
pip                   : 24.1.2
Cython                : None
sphinx                : None
IPython               : None
adbc-driver-postgresql: None
adbc-driver-sqlite    : None
bs4                   : None
bottleneck            : None
fastparquet           : None
fsspec                : None
html5lib              : None
hypothesis            : None
gcsfs                 : None
jinja2                : None
lxml.etree            : None
matplotlib            : None
numba                 : None
numexpr               : None
odfpy                 : None
openpyxl              : None
psycopg2              : None
pymysql               : None
pyarrow               : 22.0.0
pyiceberg             : None
pyreadstat            : None
pytest                : None
python-calamine       : None
pytz                  : None
pyxlsb                : None
s3fs                  : None
scipy                 : None
sqlalchemy            : None
tables                : None
tabulate              : None
xarray                : None
xlrd                  : None
xlsxwriter            : None
zstandard             : None
qtpy                  : None
pyqt5                 : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Arrowpyarrow functionalityBugNumeric OperationsArithmetic, Comparison, and Logical operationsStringsString extension data type and string data

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions