pandas-dev/pandas · error · TypeError
operation '{name}' not supported for dtype '{self.dtype}'
Error message
operation '{name}' not supported for dtype '{self.dtype}' What it means
Raised in _accumulate when pyarrow.compute raises ArrowNotImplementedError while computing a cumulative operation (cumsum/cummax/cummin/cumprod). pandas wraps it as a TypeError naming the unsupported dtype so users get a clear, dtype-specific failure.
Source
Thrown at pandas/core/arrays/arrow/array.py:2406
convert_to_int = (
pa.types.is_temporal(pa_dtype) and name in ["cummax", "cummin"]
) or (pa.types.is_duration(pa_dtype) and name == "cumsum")
if convert_to_int:
if pa_dtype.bit_width == 32:
data_to_accum = data_to_accum.cast(pa.int32())
else:
data_to_accum = data_to_accum.cast(pa.int64())
if name in ("cummax", "cummin") and pa.types.is_floating(data_to_accum.type):
kwargs["start"] = float("-inf") if name == "cummax" else float("inf")
try:
result = pyarrow_meth(data_to_accum, skip_nulls=skipna, **kwargs)
except pa.ArrowNotImplementedError as err:
msg = f"operation '{name}' not supported for dtype '{self.dtype}'"
raise TypeError(msg) from err
if convert_to_int:
result = result.cast(pa_dtype)
return self._from_pyarrow_array(result)
def _str_accumulate(
self, name: str, *, skipna: bool = True, **kwargs
) -> ArrowExtensionArray | ExtensionArray:
"""
Accumulate implementation for strings, see `_accumulate` docstring for details.
pyarrow.compute does not implement these methods for strings.
"""
if name == "cumprod":
msg = f"operation '{name}' not supported for dtype '{self.dtype}'"
raise TypeError(msg)
View on GitHub (pinned to 71959b8cb9)
Solutions
- Cast to a numeric dtype that supports the operation: `s.astype("int64[pyarrow]").cumsum()`.
- Pick a different accumulation method that is supported for the dtype (e.g. cummax/cummin for temporal types).
- If you need cumprod on integers, the operation is unsupported in pyarrow; compute it via numpy instead.
Example fix
// before
s = pd.Series([1, 2, 3], dtype="duration[ns][pyarrow]")
s.cumsum()
// after
s.astype("int64[pyarrow]").cumsum() Defensive patterns
Strategy: validation
Validate before calling
SUPPORTED_CUMULATIVE = {"cumsum": {"int", "float"}, "cumprod": {"float"}, "cummax": {"int", "float", "temporal"}, "cummin": {"int", "float", "temporal"}}
def can_accumulate(arr, name) -> bool:
kind = getattr(arr.dtype, "kind", None)
families = {"int" if kind in "iu" else "float" if kind == "f" else "temporal" if kind in "mM" else None}
return any(f in SUPPORTED_CUMULATIVE.get(name, set()) for f in families if f) Type guard
def supports_cumulative(arr, name) -> bool:
# conservative check; final answer is pyarrow's kernel availability
try:
import pyarrow.compute as pc
return getattr(pc, name, None) is not None
except Exception:
return False Try / catch
try:
s.cumsum()
except TypeError as e:
if "not supported for dtype" in str(e):
s.astype("int64[pyarrow]").cumsum()
else:
raise Prevention
- Check dtype.kind before applying cumulative reductions.
- Keep a list of dtype-supported accumulations per column in ETL metadata.
- Cast temporal/duration columns to int representation before numeric cum ops.
When it happens
Trigger: Calling `Series.cumsum/cumprod/cummax/cummin` on a pyarrow-backed Series whose dtype has no pyarrow kernel — e.g. `cumsum` on a `duration[ns][pyarrow]` Series, or `cumprod` on most non-float dtypes.
Common situations: Using cumulative reductions on temporal/duration/decimal/string arrow columns, or assuming numpy-style cumsum works uniformly across all dtypes.
Related errors
- Can only use the '.list' accessor with 'list[pyarrow]' dtype
- Can only use the '.struct' accessor with 'struct[pyarrow]' d
- Invalid value '{value!s}' for dtype '{self.dtype}'
- '{type(self).__name__}' with dtype {self.dtype} does not sup
- Cannot interpolate with {self.dtype} dtype
AI-assisted analysis of pandas-dev/pandas@71959b8cb9 (2026-08-07).
Data as JSON: /api/errors/7f2a432e26b38a84.
Report an issue: GitHub.