{"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/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/array_algos/masked_accumulations.py#L34-L70","documentation":"Raised by _cum_func in masked_accumulations.py:52 as a NotImplementedError when a masked accumulation is requested on an array whose dtype kind is not f (float), i (signed int), u (unsigned int), or b (bool). The masked accumulation path computes min/max fill values from np.iinfo/np.finfo, which only exist for those kinds; any other dtype (object, str, complex, datetime) is unsupported and rejected up front.","triggerScenarios":"Calling cumsum/cumprod/cummin/cummax on a masked ExtensionArray (e.g. IntegerArray, FloatingArray, BooleanArray) backed by an unsupported dtype, or reaching the masked path with an object/complex array. Hit at masked_accumulations.py:42-54 when values.dtype.kind is none of f/i/u/b.","commonSituations":"Custom ExtensionArrays with non-numeric backing dtypes routed through the masked accumulation; converting an object-dtype column to a masked array and calling cumsum; bugs in EA dispatch that send datetime/string arrays into the numeric masked path.","solutions":["Cast the data to a supported numeric dtype before accumulating: s.astype('Int64').cumsum() or s.astype('Float64').cumsum().","Use the appropriate accumulation for the dtype - datetimelike arrays have their own accumulator (datetimelike_accumulations).","For EA authors: implement cumsum/cummin/etc. directly on your array subclass instead of routing non-numeric dtypes through the shared masked path."],"exampleFix":"// before\narr = pd.arrays.IntegerArray(np.array(['1','2'], dtype=object), np.array([False,False]))\narr.cumsum()  # unsupported kind\n// after\ns = pd.Series(['1','2']).astype('Int64')\ns.cumsum()","handlingStrategy":"validation","validationCode":"kind = getattr(values, 'dtype', type(values)).kind if hasattr(values, 'dtype') else None\nif kind not in 'fiub':\n    raise NotImplementedError(f'masked accumulation unsupported for dtype kind {kind!r}; cast to numeric first')","typeGuard":"def masked_accum_dtype_ok(values) -> bool:\n    import numpy as np\n    dt = getattr(values, 'dtype', None)\n    return dt is not None and dt.kind in 'fiub'","tryCatchPattern":null,"preventionTips":["Cast object/string columns to a numeric nullable dtype (Int64/Float64) before calling cumsum/cumprod.","EA authors: route non-numeric dtypes to their own accumulator implementations."],"tags":["pandas","accumulation","masked-array","dtype","extension-array"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}