pandas-dev/pandas · error · NotImplementedError
cannot perform {name} with type {self.dtype}
Error message
cannot perform {name} with type {self.dtype} What it means
Base ExtensionArray._accumulate (base.py:2411) raises NotImplementedError with the requested accumulation name (e.g. cumsum, cumprod, cummin, cummax). The base class has no generic accumulation; numeric EAs like IntegerArray/FloatingArray override _accumulate. Hitting this means the EA type does not implement cumulative operations.
Source
Thrown at pandas/core/arrays/base.py:2411
NotImplementedError : subclass does not define accumulations
See Also
--------
api.extensions.ExtensionArray._concat_same_type : Concatenate multiple
array of this dtype.
api.extensions.ExtensionArray.view : Return a view on the array.
api.extensions.ExtensionArray._explode : Transform each element of
list-like to a row.
Examples
--------
>>> arr = pd.array([1, 2, 3])
>>> arr._accumulate(name="cumsum")
<IntegerArray>
[1, 3, 6]
Length: 3, dtype: Int64
"""
raise NotImplementedError(f"cannot perform {name} with type {self.dtype}")
def _reduce(
self, name: str, *, skipna: bool = True, keepdims: bool = False, **kwargs
):
"""
Return a scalar result of performing the reduction operation.
This method dispatches to the appropriate reduction method (e.g.,
sum, mean, min, max) based on the `name` parameter and returns
the result.
Parameters
----------
name : str
Name of the function, supported values are:
{ any, all, min, max, sum, mean, median, prod,
std, var, sem, kurt, skew }.
skipna : bool, default TrueView on GitHub (pinned to 71959b8cb9)
Solutions
- Override _accumulate(self, name, *, skipna, **kwargs) in the ExtensionArray subclass.
- Convert the column to a numeric dtype first: s.astype('Int64').cumsum().
- Select only numeric columns before applying cumulative reductions (df.select_dtypes(include='number')).
- Fill/transform the data so a supported EA handles it.
Example fix
# before
s = pd.array([...], dtype="MyCustomEA")
s.cumsum() # raises
# after
s.astype("Float64").cumsum() Defensive patterns
Strategy: type-guard
Validate before calling
def can_accumulate(dtype, name):
import pandas as pd
if pd.api.types.is_numeric_dtype(dtype):
return True
return False Type guard
def is_numeric_ea(dtype) -> bool:
import pandas as pd
return pd.api.types.is_numeric_dtype(dtype) Try / catch
try:
s.cumsum()
except NotImplementedError as e:
if "cannot perform" in str(e):
s.astype("Float64").cumsum()
else:
raise Prevention
- Implement _accumulate on custom EA subclasses
- Restrict cumulative reductions to numeric columns
- Convert dtypes before cumulative ops
When it happens
Trigger: Calling s.cumsum(), s.cumprod(), s.cummin(), or s.cummax() on a Series whose backing ExtensionArray does not implement _accumulate (e.g. some custom or non-numeric EA).
Common situations: Running cumulative reductions on a string or custom EA; using a third-party extension dtype that never declared accumulation support; notebooks that apply cumsum across all columns including non-numeric ones.
Related errors
- {type(self)} does not implement __setitem__.
- {type(self).__name__} does not implement interpolate
- function is not implemented for this dtype: {self.dtype}
- operation '{name}' not supported for dtype '{self.dtype}'
- Default 'empty' implementation is invalid for dtype='{dtype}
AI-assisted analysis of pandas-dev/pandas@71959b8cb9 (2026-08-07).
Data as JSON: /api/errors/1e61ee7fa869f23a.
Report an issue: GitHub.