pandas-dev/pandas · error · NotImplementedError
No accumulation for implemented on BaseMaskedArray
Error message
No accumulation for {func} implemented on BaseMaskedArray What it means
NotImplementedError raised in masked_accumulations when the func is not one of np.cumprod, np.maximum.accumulate, np.cumsum, np.minimum.accumulate. The fill-value lookup dict has no entry for the func, so it is rejected.
Solutions
- Use a supported accumulation method (cumsum, cumprod, cummin, cummax).
- Implement the accumulation in the calling code instead of relying on the masked dispatch.
Defensive patterns
Strategy: validation
Validate before calling
import numpy as np
SUPPORTED_FUNCS = {np.cumprod, np.maximum.accumulate, np.cumsum, np.minimum.accumulate}
def safe_accum(func, values):
if func not in SUPPORTED_FUNCS:
raise ValueError(f'{func.__name__} is not a supported masked accumulation')
return func(values) Try / catch
try:
func(values)
except NotImplementedError as e:
if 'No accumulation for' in str(e):
np.cumsum(values) # fall back to a supported accumulator
else:
raise Prevention
- Only route the four supported numpy accumulators through masked arrays.
- For custom reductions, operate on the underlying numpy buffer directly.
When it happens
Trigger: Internal dispatch: routing an unsupported accumulation (e.g. np.cumprod on a path expecting something else, or a custom ufunc) through masked accumulations.
Common situations: Custom array code or third-party extension arrays that hand an unsupported accumulator to the masked path.
Related errors
- No masked accumulation defined for dtype
- mask must be a 1D list-like
- No accumulation for implemented on BaseMaskedArray
- Accumulation not supported for
- Accumulation not supported for
AI-assisted analysis of pandas-dev/pandas@3b7651241d (2026-08-11).
Data as JSON: /api/errors/32083ada175af0b4.
Report an issue: GitHub.
Appendix: 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 3b7651241d)