pandas-dev/pandas · error · NotImplementedError
No accumulation for {func} implemented on BaseMaskedArray
Error message
No accumulation for {func} implemented on BaseMaskedArray What it means
Raised by _cum_func in masked_accumulations.py:63 as a NotImplementedError when the accumulation func passed in is not one of np.cumsum, np.cumprod, np.maximum.accumulate, np.minimum.accumulate. The fill-value lookup dict only contains those four; any other numpy accumulator raises KeyError, which is converted to NotImplementedError. This is an internal dispatch guard - public cum methods only ever pass one of the four supported funcs.
Source
Thrown at pandas/core/array_algos/masked_accumulations.py:63
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)
values = func(values)
return values, mask
def cumsum(
values: np.ndarray, mask: npt.NDArray[np.bool_], *, skipna: bool = True
) -> tuple[np.ndarray, npt.NDArray[np.bool_]]:
return _cum_func(np.cumsum, values, mask, skipna=skipna)
View on GitHub (pinned to 71959b8cb9)
Solutions
- Use only the supported accumulators: cumsum, cumprod, cummin, cummax.
- For custom accumulation needs, implement the loop directly on the array rather than routing through _cum_func.
- If you are an EA author and need a new accumulator, add it to the fill_value dict and contribute upstream.
Example fix
// before from pandas.core.array_algos.masked_accumulations import _cum_func _cum_func(np.add.accumulate, vals, mask) # unsupported // after _cum_func(np.cumsum, vals, mask) # supported
Defensive patterns
Strategy: validation
Validate before calling
import numpy as np
_ALLOWED = {np.cumsum, np.cumprod, np.maximum.accumulate, np.minimum.accumulate}
if func not in _ALLOWED:
raise NotImplementedError(f'{func} not supported by masked accumulation; use one of cumsum/cumprod/cummin/cummax') Type guard
def supported_masked_cum(func) -> bool:
import numpy as np
return func in {np.cumsum, np.cumprod, np.maximum.accumulate, np.minimum.accumulate} Prevention
- Use only the four public cum methods on masked arrays.
- Internal callers: never pass arbitrary numpy accumulators to _cum_func.
When it happens
Trigger: Internally dispatching an unsupported numpy accumulator (e.g. np.add.accumulate) on a masked numeric array. Hit at masked_accumulations.py:55-65 when func is not a key in the supported dict.
Common situations: Custom EA code or third-party integrations calling _cum_func directly with an unsupported func; pandas internal refactors that introduce new cum variants before extending the dispatch table; misuse of the internal API.
Related errors
- No accumulation for {func} implemented on BaseMaskedArray
- No masked accumulation defined for dtype {values.dtype.type}
- Could not infer freq from start/end
- keyword error in function call '{node.func.id}'
- Invalid binary operator {op!r}, valid operators are {keys}
AI-assisted analysis of pandas-dev/pandas@71959b8cb9 (2026-08-07).
Data as JSON: /api/errors/32083ada175af0b4.
Report an issue: GitHub.