{"record":{"id":"95a1b41e213ee062","repo":"pandas-dev/pandas","slug":"no-masked-accumulation-defined-for-dtype-values-d","errorCode":null,"errorMessage":"No masked accumulation defined for dtype {values.dtype.type}","messagePattern":"No masked accumulation defined for dtype (.+?)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"pandas/core/array_algos/masked_accumulations.py","lineNumber":52,"sourceCode":"        Numpy array with the values (can be of any dtype that support the\n        operation).\n    mask : np.ndarray\n        Boolean numpy array (True values indicate missing values).\n    skipna : bool, default True\n        Whether to skip NA.\n    \"\"\"\n    dtype_info: np.iinfo | np.finfo\n    if values.dtype.kind == \"f\":\n        dtype_info = np.finfo(values.dtype.type)\n    elif values.dtype.kind in \"iu\":\n        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)","sourceCodeStart":34,"sourceCodeEnd":70,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/array_algos/masked_accumulations.py#L34-L70","documentation":"NotImplementedError raised in masked_accumulations when the values array has a dtype kind outside float (f), signed/unsigned int (iu), or bool (b). Masked numeric accumulations are only defined for those kinds; anything else (complex, object, etc.) is rejected before computing.","triggerScenarios":"Internal dispatch: calling _masked_accumulations / cumsum / cumprod on a masked array of unsupported dtype (e.g. complex128).","commonSituations":"Building custom ExtensionArray subtypes and routing their cum ops through the masked accumulator path with an unusual dtype.","solutions":["Cast the array to a supported dtype (float/int/bool) before accumulating.","Implement accumulation directly on the ExtensionArray rather than routing through masked_accumulations."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"import numpy as np\ndef safe_masked_accum(values, func):\n    if values.dtype.kind not in 'fiub':\n        values = values.astype('float64')\n    return func(values)","typeGuard":"def is_supported_numeric_dtype(arr) -> bool:\n    return arr.dtype.kind in 'fiub'","tryCatchPattern":"try:\n    func(values)\nexcept NotImplementedError as e:\n    if 'No masked accumulation' in str(e):\n        func(values.astype('float64'))\n    else:\n        raise","preventionTips":["Ensure masked arrays are float/int/bool before cumsum/cumprod.","Cast custom extension array values to float64 when routing through masked accumulations."],"tags":["internal","accumulation","dtype","masked-array"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}