Skip to content

BUG: Operations not implemented for non-1D ExtensionArrays  #61866

Open
@eicchen

Description

@eicchen

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

# mypy: ignore-errors
import pandas as pd
import numpy as np
import pandas._testing as tm

df = pd.DataFrame(np.arange(50).reshape(10, 5)).notna().values

# -> works
NP_array = pd.array([i for i in range(10)], dtype=tm.SIGNED_INT_NUMPY_DTYPES[0]).reshape(10,1) #dtype: NumpyExtensionArray

# -> doesnt work (NotImplemented)
EA_array = pd.array([i for i in range(10)], dtype=tm.SIGNED_INT_EA_DTYPES[0]).reshape(10,1)    #dtype: IntExtensionArray

print(df * NP_array)
# NotImplementedError: can only perform ops with 1-d structures
print(df * EA_array)

Issue Description

I was working on creating test cases for ExtensionArrays following comments on PR #61828 when I realized that I could not use the '&' operation on EAs like I could with NP arrays.

After a bit of digging around, it appears they both call self._logical_method, but whereas NP returns NotImplemented and continues operation, EA raises an error.

If someone wants to take a look while I work on something else, they are more than welcome to, otherwise I can work out a fix when I come back to it.

I have found that to be the case for both '*' and '&' so it's probably something deeper there

Expected Behavior

  • Operators should function the same for both Numpy arrays and other ExtensionArrays

Installed Versions

INSTALLED VERSIONS

commit : 8a1d5a0
python : 3.10.17
python-bits : 64
OS : Linux
OS-release : 6.11.0-29-generic
Version : #29~24.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Jun 26 14:16:59 UTC 2
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8

pandas : 3.0.0.dev0+2177.g8a1d5a06f9
numpy : 2.2.5
dateutil : 2.9.0.post0
pip : 25.1.1
Cython : 3.0.12
sphinx : 8.1.3
IPython : 8.36.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : 4.13.4
bottleneck : 1.4.2
fastparquet : 2024.11.0
fsspec : 2025.3.2
html5lib : 1.1
hypothesis : 6.131.15
gcsfs : 2025.3.2
jinja2 : 3.1.6
lxml.etree : 5.4.0
matplotlib : 3.10.3
numba : 0.61.2
numexpr : 2.10.2
odfpy : None
openpyxl : 3.1.5
psycopg2 : 2.9.9
pymysql : 1.4.6
pyarrow : 20.0.0
pyiceberg : None
pyreadstat : 1.2.8
pytest : 8.3.5
python-calamine : None
pytz : 2025.2
pyxlsb : 1.0.10
s3fs : 2025.3.2
scipy : 1.15.2
sqlalchemy : 2.0.40
tables : 3.10.1
tabulate : 0.9.0
xarray : 2025.4.0
xlrd : 2.0.1
xlsxwriter : 3.2.3
zstandard : 0.23.0
qtpy : None
pyqt5 : None
None

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugNA - MaskedArraysRelated to pd.NA and nullable extension arraysNumeric OperationsArithmetic, Comparison, and Logical operations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions