{"record":{"id":"c436b2beb515c682","repo":"pandas-dev/pandas","slug":"no-accumulation-for-func-implemented-on-basemask","errorCode":null,"errorMessage":"No accumulation for {func} implemented on BaseMaskedArray","messagePattern":"No accumulation for (.+?) implemented on BaseMaskedArray","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pandas/core/array_algos/datetimelike_accumulations.py","lineNumber":78,"sourceCode":"    Accumulations for 1D datetimelike arrays.\n\n    Parameters\n    ----------\n    func : np.cumsum, np.maximum.accumulate, np.minimum.accumulate\n    values : np.ndarray\n        Numpy array with the values (can be of any dtype that support the\n        operation). Values is changed is modified inplace.\n    skipna : bool, default True\n        Whether to skip NA.\n    \"\"\"\n    try:\n        fill_value = {\n            np.maximum.accumulate: np.iinfo(np.int64).min,\n            np.cumsum: 0,\n            np.minimum.accumulate: np.iinfo(np.int64).max,\n        }[func]\n    except KeyError as err:\n        raise ValueError(\n            f\"No accumulation for {func} implemented on BaseMaskedArray\"\n        ) from err\n\n    mask = isna(values)\n    y = values.view(\"i8\")\n    y[mask] = fill_value\n\n    if not skipna:\n        mask = np.maximum.accumulate(mask)\n\n    # GH 57956\n    result = func(y, axis=0)\n    if func is np.cumsum:\n        # GH#66551: cummin/cummax cannot leave the range, cumsum can\n        _check_cumsum_overflow(y, result, mask)\n    result[mask] = iNaT\n\n    if values.dtype.kind in \"mM\":","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/array_algos/datetimelike_accumulations.py#L60-L96","documentation":"Raised by _cum_func in datetimelike_accumulations.py:78 as a ValueError when an unsupported accumulation function is dispatched on a datetimelike BaseMaskedArray. The internal _cum_func only knows three numpy accumulators (np.cumsum, np.maximum.accumulate, np.minimum.accumulate); anything else hits the KeyError -> ValueError path. This is an internal dispatch guard - end users normally only reach it through cumsum/cummin/cummax on the supported dtypes.","triggerScenarios":"Internally calling _cum_func(np.cumprod, datetimelike_values) or any accumulation not in {cumsum, max.accumulate, min.accumulate} on a datetime64/timedelta64 array. Hit at datetimelike_accumulations.py:71-80 when func is not in the supported dict.","commonSituations":"Third-party ExtensionArray subclasses routing an unsupported cum func through the datetimelike accumulator; calling cumprod on a timedelta Series (pandas usually blocks this earlier, but a custom path can reach _cum_func); version changes that add new accumulation entry points before updating the dispatch table.","solutions":["Use only cumsum, cummin, or cummax on datetime64/timedelta64 Series - these are the implemented accumulations.","If you need cumprod on numeric data, ensure the array is a numeric dtype (int/float) rather than datetimelike.","For ExtensionArray authors: register the accumulation in the dispatch table or override the cum method on your array class."],"exampleFix":"// before\ns = pd.Series(pd.to_timedelta([1,2,3]))\n# internal dispatch with np.cumprod reaches _cum_func\n// after\ns = pd.Series([1,2,3])  # plain numeric\ns.cumprod()","handlingStrategy":"validation","validationCode":"import numpy as np\n_ALLOWED = {np.cumsum, np.maximum.accumulate, np.minimum.accumulate}\nif func not in _ALLOWED:\n    raise ValueError(f'{func} is not implemented for datetimelike accumulations; use cumsum/cummin/cummax')","typeGuard":"def supported_datetimelike_cum(func) -> bool:\n    import numpy as np\n    return func in {np.cumsum, np.maximum.accumulate, np.minimum.accumulate}","tryCatchPattern":null,"preventionTips":["Only call cumsum/cummin/cummax on datetime64/timedelta64 Series.","ExtensionArray authors: override cum methods instead of routing new accumulators through the shared dispatch."],"tags":["pandas","accumulation","datetimelike","internal","dispatch"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}