-
- Notifications
You must be signed in to change notification settings - Fork 19.4k
Description
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
import pandas as pd import pyarrow as pa s = pd.Series([None, None], dtype=pd.ArrowDtype(pa.float64())) s.pow(2)Issue Description
The snippet above succeeds with pandas 2.x, but raises a ArrowNotImplementedError: Function 'replace_with_mask' has no kernel matching input types (double, null, double) with pandas 3.x
--------------------------------------------------------------------------- ArrowNotImplementedError Traceback (most recent call last) Cell In[1], line 6 2 import pyarrow as pa 5 s = pd.Series([None, None], dtype=pd.ArrowDtype(pa.float64())) ----> 6 s.pow(2) File ~/gh/dask/.venv/lib/python3.12/site-packages/pandas/core/series.py:6591, in Series.pow(self, other, level, fill_value, axis) 6589 @Appender(ops.make_flex_doc("pow", "series")) 6590 def pow(self, other, level=None, fill_value=None, axis: Axis = 0) -> Series: -> 6591 return self._flex_method( 6592 other, operator.pow, level=level, fill_value=fill_value, axis=axis 6593 ) File ~/gh/dask/.venv/lib/python3.12/site-packages/pandas/core/series.py:6050, in Series._flex_method(self, other, op, level, fill_value, axis) 6047 return op(self, fill_value) 6048 self = self.fillna(fill_value) -> 6050 return op(self, other) File ~/gh/dask/.venv/lib/python3.12/site-packages/pandas/core/ops/common.py:70, in _unpack_zerodim_and_defer.<locals>.new_method(self, other) 66 return NotImplemented 68 other = item_from_zerodim(other) ---> 70 return method(self, other) File ~/gh/dask/.venv/lib/python3.12/site-packages/pandas/core/arraylike.py:245, in OpsMixin.__pow__(self, other) 243 @unpack_zerodim_and_defer("__pow__") 244 def __pow__(self, other): --> 245 return self._arith_method(other, operator.pow) File ~/gh/dask/.venv/lib/python3.12/site-packages/pandas/core/series.py:5924, in Series._arith_method(self, other, op) 5922 def _arith_method(self, other, op): 5923 self, other = self._align_for_op(other) -> 5924 return base.IndexOpsMixin._arith_method(self, other, op) File ~/gh/dask/.venv/lib/python3.12/site-packages/pandas/core/base.py:1485, in IndexOpsMixin._arith_method(self, other, op) 1482 rvalues = np.arange(rvalues.start, rvalues.stop, rvalues.step) 1484 with np.errstate(all="ignore"): -> 1485 result = ops.arithmetic_op(lvalues, rvalues, op) 1487 return self._construct_result(result, name=res_name, other=other) File ~/gh/dask/.venv/lib/python3.12/site-packages/pandas/core/ops/array_ops.py:272, in arithmetic_op(left, right, op) 259 # NB: We assume that extract_array and ensure_wrapped_if_datetimelike 260 # have already been called on `left` and `right`, 261 # and `maybe_prepare_scalar_for_op` has already been called on `right` 262 # We need to special-case datetime64/timedelta64 dtypes (e.g. because numpy 263 # casts integer dtypes to timedelta64 when operating with timedelta64 - GH#22390) 265 if ( 266 should_extension_dispatch(left, right) 267 or isinstance(right, (Timedelta, BaseOffset, Timestamp)) (...) 270 # Timedelta/Timestamp and other custom scalars are included in the check 271 # because numexpr will fail on it, see GH#31457 --> 272 res_values = op(left, right) 273 else: 274 # TODO we should handle EAs consistently and move this check before the if/else 275 # (https://github.com/pandas-dev/pandas/issues/41165) 276 # error: Argument 2 to "_bool_arith_check" has incompatible type 277 # "Union[ExtensionArray, ndarray[Any, Any]]"; expected "ndarray[Any, Any]" 278 _bool_arith_check(op, left, right) # type: ignore[arg-type] File ~/gh/dask/.venv/lib/python3.12/site-packages/pandas/core/ops/common.py:70, in _unpack_zerodim_and_defer.<locals>.new_method(self, other) 66 return NotImplemented 68 other = item_from_zerodim(other) ---> 70 return method(self, other) File ~/gh/dask/.venv/lib/python3.12/site-packages/pandas/core/arraylike.py:245, in OpsMixin.__pow__(self, other) 243 @unpack_zerodim_and_defer("__pow__") 244 def __pow__(self, other): --> 245 return self._arith_method(other, operator.pow) File ~/gh/dask/.venv/lib/python3.12/site-packages/pandas/core/arrays/arrow/array.py:1055, in ArrowExtensionArray._arith_method(self, other, op) 1053 parr = result._pa_array 1054 mask = pc.is_nan(parr).to_numpy() -> 1055 arr = pc.replace_with_mask(parr, mask, pa.scalar(None, type=parr.type)) 1056 result = type(self)(arr) 1057 return result File ~/gh/dask/.venv/lib/python3.12/site-packages/pyarrow/compute.py:252, in _make_generic_wrapper.<locals>.wrapper(memory_pool, *args) 250 if args and isinstance(args[0], Expression): 251 return Expression._call(func_name, list(args)) --> 252 return func.call(args, None, memory_pool) File ~/gh/dask/.venv/lib/python3.12/site-packages/pyarrow/_compute.pyx:399, in pyarrow._compute.Function.call() File ~/gh/dask/.venv/lib/python3.12/site-packages/pyarrow/error.pxi:155, in pyarrow.lib.pyarrow_internal_check_status() File ~/gh/dask/.venv/lib/python3.12/site-packages/pyarrow/error.pxi:92, in pyarrow.lib.check_status() ArrowNotImplementedError: Function 'replace_with_mask' has no kernel matching input types (double, null, double)Expected Behavior
The pandas 2.x output:
0 <NA> 1 <NA> dtype: double[pyarrow] Installed Versions
In [2]: pd.show_versions()
INSTALLED VERSIONS
commit : d815947
python : 3.12.8
python-bits : 64
OS : Darwin
OS-release : 24.6.0
Version : Darwin Kernel Version 24.6.0: Mon Jul 14 11:30:40 PDT 2025; root:xnu-11417.140.69~1/RELEASE_ARM64_T6041
machine : arm64
processor : arm
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 3.0.0.dev0+2463.gd8159471b1
numpy : 2.4.0.dev0+git20250808.622f874
dateutil : 2.9.0.post0
pip : None
Cython : None
sphinx : None
IPython : 9.4.0
adbc-driver-postgresql: None
adbc-driver-sqlite : None
bs4 : None
bottleneck : None
fastparquet : None
fsspec : 2025.3.2
html5lib : None
hypothesis : 6.136.1
gcsfs : None
jinja2 : 3.1.6
lxml.etree : None
matplotlib : 3.10.3
numba : None
numexpr : None
odfpy : None
openpyxl : None
psycopg2 : None
pymysql : None
pyarrow : 21.0.0
pyiceberg : None
pyreadstat : None
pytest : 8.4.1
python-calamine : None
pytz : 2025.2
pyxlsb : None
s3fs : 2025.7.0
scipy : None
sqlalchemy : 2.0.41
tables : None
tabulate : None
xarray : 2025.9.0
xlrd : None
xlsxwriter : None
zstandard : None
qtpy : None
pyqt5 : None