{"record":{"id":"32083ada175af0b4","repo":"pandas-dev/pandas","slug":"no-accumulation-for-func-implemented-on-basemask-32083a","errorCode":null,"errorMessage":"No accumulation for {func} implemented on BaseMaskedArray","messagePattern":"No accumulation for (.+?) implemented on BaseMaskedArray","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"pandas/core/array_algos/masked_accumulations.py","lineNumber":63,"sourceCode":"        dtype_info = np.iinfo(values.dtype.type)\n    elif values.dtype.kind == \"b\":\n        # Max value of bool is 1, but since we are setting into a boolean\n        # array, 255 is fine as well. Min value has to be 0 when setting\n        # into the boolean array.\n        dtype_info = np.iinfo(np.uint8)\n    else:\n        raise NotImplementedError(\n            f\"No masked accumulation defined for dtype {values.dtype.type}\"\n        )\n    try:\n        fill_value = {\n            np.cumprod: 1,\n            np.maximum.accumulate: dtype_info.min,\n            np.cumsum: 0,\n            np.minimum.accumulate: dtype_info.max,\n        }[func]\n    except KeyError as err:\n        raise NotImplementedError(\n            f\"No accumulation for {func} implemented on BaseMaskedArray\"\n        ) from err\n\n    values[mask] = fill_value\n\n    if not skipna:\n        mask = np.maximum.accumulate(mask)\n\n    values = func(values)\n    return values, mask\n\n\ndef cumsum(\n    values: np.ndarray, mask: npt.NDArray[np.bool_], *, skipna: bool = True\n) -> tuple[np.ndarray, npt.NDArray[np.bool_]]:\n    return _cum_func(np.cumsum, values, mask, skipna=skipna)\n\n","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/array_algos/masked_accumulations.py#L45-L81","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nfrom pandas.core.array_algos.masked_accumulations import _cum_func\n_cum_func(np.add.accumulate, vals, mask)  # unsupported\n// after\n_cum_func(np.cumsum, vals, mask)  # supported","handlingStrategy":"validation","validationCode":"import numpy as np\n_ALLOWED = {np.cumsum, np.cumprod, np.maximum.accumulate, np.minimum.accumulate}\nif func not in _ALLOWED:\n    raise NotImplementedError(f'{func} not supported by masked accumulation; use one of cumsum/cumprod/cummin/cummax')","typeGuard":"def supported_masked_cum(func) -> bool:\n    import numpy as np\n    return func in {np.cumsum, np.cumprod, np.maximum.accumulate, np.minimum.accumulate}","tryCatchPattern":null,"preventionTips":["Use only the four public cum methods on masked arrays.","Internal callers: never pass arbitrary numpy accumulators to _cum_func."],"tags":["pandas","accumulation","masked-array","internal","dispatch"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}