Pandas version checks

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

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

  • [x] 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 : 8a1d5a06f9fb3c232249e3ed301932053efb06d8 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

Comment From: tisjayy

I confirmed the behavior, binary ops like * and & fail on 2D ExtensionArrays (Int64) but work fine with equivalent NumPy arrays. I'll look into _arith_method and _logical_method handling for 2D EAs and see if broadcasting can be better supported.

Comment From: tisjayy

take

Comment From: tisjayy

I changed the logical method in boolean.py so ExtensionArrays handle these cases like NumPy arrays do by returning NotImplemented when they can’t perform the operation. So Python can try other ways instead of showing error. Lets see if it passes the code checks.