{"record":{"id":"1e61ee7fa869f23a","repo":"pandas-dev/pandas","slug":"cannot-perform-name-with-type-self-dtype","errorCode":null,"errorMessage":"cannot perform {name} with type {self.dtype}","messagePattern":"cannot perform (.+?) with type (.+?)","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/base.py","lineNumber":2411,"sourceCode":"        NotImplementedError : subclass does not define accumulations\n\n        See Also\n        --------\n        api.extensions.ExtensionArray._concat_same_type : Concatenate multiple\n            array of this dtype.\n        api.extensions.ExtensionArray.view : Return a view on the array.\n        api.extensions.ExtensionArray._explode : Transform each element of\n            list-like to a row.\n\n        Examples\n        --------\n        >>> arr = pd.array([1, 2, 3])\n        >>> arr._accumulate(name=\"cumsum\")\n        <IntegerArray>\n        [1, 3, 6]\n        Length: 3, dtype: Int64\n        \"\"\"\n        raise NotImplementedError(f\"cannot perform {name} with type {self.dtype}\")\n\n    def _reduce(\n        self, name: str, *, skipna: bool = True, keepdims: bool = False, **kwargs\n    ):\n        \"\"\"\n        Return a scalar result of performing the reduction operation.\n\n        This method dispatches to the appropriate reduction method (e.g.,\n        sum, mean, min, max) based on the `name` parameter and returns\n        the result.\n\n        Parameters\n        ----------\n        name : str\n            Name of the function, supported values are:\n            { any, all, min, max, sum, mean, median, prod,\n            std, var, sem, kurt, skew }.\n        skipna : bool, default True","sourceCodeStart":2393,"sourceCodeEnd":2429,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/base.py#L2393-L2429","documentation":"_accumulate dispatches cumulative reductions (cumsum, cumprod, cummin, cummax, cummax). The base ExtensionArray provides no default — it raises NotImplementedError naming the requested operation and the array's dtype, because accumulation semantics (especially NA propagation and casting) are dtype-specific. Subclasses opt in.","triggerScenarios":"Calling Series.cumsum / cummax / cummin / cumprod on a Series backed by a custom ExtensionArray that did not override _accumulate. Reached via df.cumsum() on a column of that dtype.","commonSituations":"Applying cumulative reductions across a mixed-dtype frame where one custom EA column lacks _accumulate. Third-party dtype that implements instantaneous reductions (_reduce) but not cumulative ones.","solutions":["Scope the cumulative op to supported columns: df.select_dtypes(include='number').cumsum().","If you own the EA, implement _accumulate handling the supported names and NA propagation per your dtype rules.","Convert the column to a backed numpy dtype before accumulating, accepting loss of NA semantics."],"exampleFix":"// before\ndf.cumsum()  # NotImplementedError: cannot perform cumsum with type ...\n\n// after\ndf.select_dtypes(include='number').cumsum()\n# or for the specific column\nseries.astype('float64').cumsum()","handlingStrategy":"fallback","validationCode":"supported = {'cumsum','cumprod','cummin','cummax'}\nfrom pandas.api.extensions import ExtensionArray\nif name in supported and getattr(type(arr), '_accumulate', None) is ExtensionArray._accumulate:\n    raise NotImplementedError(f'{type(arr).__name__} does not support {name}')","typeGuard":"def supports_accumulate(cls) -> bool:\n    return getattr(cls, '_accumulate', None) is not ExtensionArray._accumulate","tryCatchPattern":"try:\n    out = series.cumsum()\nexcept NotImplementedError:\n    out = series.astype('float64').cumsum()","preventionTips":["Restrict cumulative ops to numeric columns via select_dtypes.","Implement _accumulate on the EA for supported names with explicit NA handling.","Cast to a numpy dtype before accumulating when NA semantics are not required."],"tags":["extension-array","not-implemented","accumulation","pandas"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}