pandas-dev/pandas · error · NotImplementedError
No masked accumulation defined for dtype {values.dtype.type}
Error message
No masked accumulation defined for dtype {values.dtype.type} What it means
Raised by _cum_func in masked_accumulations.py:52 as a NotImplementedError when a masked accumulation is requested on an array whose dtype kind is not f (float), i (signed int), u (unsigned int), or b (bool). The masked accumulation path computes min/max fill values from np.iinfo/np.finfo, which only exist for those kinds; any other dtype (object, str, complex, datetime) is unsupported and rejected up front.
Source
Thrown at pandas/core/array_algos/masked_accumulations.py:52
Numpy array with the values (can be of any dtype that support the
operation).
mask : np.ndarray
Boolean numpy array (True values indicate missing values).
skipna : bool, default True
Whether to skip NA.
"""
dtype_info: np.iinfo | np.finfo
if values.dtype.kind == "f":
dtype_info = np.finfo(values.dtype.type)
elif values.dtype.kind in "iu":
dtype_info = np.iinfo(values.dtype.type)
elif values.dtype.kind == "b":
# Max value of bool is 1, but since we are setting into a boolean
# array, 255 is fine as well. Min value has to be 0 when setting
# into the boolean array.
dtype_info = np.iinfo(np.uint8)
else:
raise NotImplementedError(
f"No masked accumulation defined for dtype {values.dtype.type}"
)
try:
fill_value = {
np.cumprod: 1,
np.maximum.accumulate: dtype_info.min,
np.cumsum: 0,
np.minimum.accumulate: dtype_info.max,
}[func]
except KeyError as err:
raise NotImplementedError(
f"No accumulation for {func} implemented on BaseMaskedArray"
) from err
values[mask] = fill_value
if not skipna:
mask = np.maximum.accumulate(mask)View on GitHub (pinned to 71959b8cb9)
Solutions
- Cast the data to a supported numeric dtype before accumulating: s.astype('Int64').cumsum() or s.astype('Float64').cumsum().
- Use the appropriate accumulation for the dtype - datetimelike arrays have their own accumulator (datetimelike_accumulations).
- For EA authors: implement cumsum/cummin/etc. directly on your array subclass instead of routing non-numeric dtypes through the shared masked path.
Example fix
// before
arr = pd.arrays.IntegerArray(np.array(['1','2'], dtype=object), np.array([False,False]))
arr.cumsum() # unsupported kind
// after
s = pd.Series(['1','2']).astype('Int64')
s.cumsum() Defensive patterns
Strategy: validation
Validate before calling
kind = getattr(values, 'dtype', type(values)).kind if hasattr(values, 'dtype') else None
if kind not in 'fiub':
raise NotImplementedError(f'masked accumulation unsupported for dtype kind {kind!r}; cast to numeric first') Type guard
def masked_accum_dtype_ok(values) -> bool:
import numpy as np
dt = getattr(values, 'dtype', None)
return dt is not None and dt.kind in 'fiub' Prevention
- Cast object/string columns to a numeric nullable dtype (Int64/Float64) before calling cumsum/cumprod.
- EA authors: route non-numeric dtypes to their own accumulator implementations.
When it happens
Trigger: Calling cumsum/cumprod/cummin/cummax on a masked ExtensionArray (e.g. IntegerArray, FloatingArray, BooleanArray) backed by an unsupported dtype, or reaching the masked path with an object/complex array. Hit at masked_accumulations.py:42-54 when values.dtype.kind is none of f/i/u/b.
Common situations: Custom ExtensionArrays with non-numeric backing dtypes routed through the masked accumulation; converting an object-dtype column to a masked array and calling cumsum; bugs in EA dispatch that send datetime/string arrays into the numeric masked path.
Related errors
- No accumulation for {func} implemented on BaseMaskedArray
- {type(arr).__name__} has no 'diff' method. Convert to a suit
- Column {colname} must have a numeric dtype. Found '{dtype}'
- Column {colname} is backed by an extension array, which is n
- No accumulation for {func} implemented on BaseMaskedArray
AI-assisted analysis of pandas-dev/pandas@71959b8cb9 (2026-08-07).
Data as JSON: /api/errors/95a1b41e213ee062.
Report an issue: GitHub.