{"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/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/arrays/base.py#L2393-L2429","documentation":"Base ExtensionArray._accumulate (base.py:2411) raises NotImplementedError with the requested accumulation name (e.g. cumsum, cumprod, cummin, cummax). The base class has no generic accumulation; numeric EAs like IntegerArray/FloatingArray override _accumulate. Hitting this means the EA type does not implement cumulative operations.","triggerScenarios":"Calling s.cumsum(), s.cumprod(), s.cummin(), or s.cummax() on a Series whose backing ExtensionArray does not implement _accumulate (e.g. some custom or non-numeric EA).","commonSituations":"Running cumulative reductions on a string or custom EA; using a third-party extension dtype that never declared accumulation support; notebooks that apply cumsum across all columns including non-numeric ones.","solutions":["Override _accumulate(self, name, *, skipna, **kwargs) in the ExtensionArray subclass.","Convert the column to a numeric dtype first: s.astype('Int64').cumsum().","Select only numeric columns before applying cumulative reductions (df.select_dtypes(include='number')).","Fill/transform the data so a supported EA handles it."],"exampleFix":"# before\ns = pd.array([...], dtype=\"MyCustomEA\")\ns.cumsum()  # raises\n\n# after\ns.astype(\"Float64\").cumsum()","handlingStrategy":"type-guard","validationCode":"def can_accumulate(dtype, name):\n    import pandas as pd\n    if pd.api.types.is_numeric_dtype(dtype):\n        return True\n    return False","typeGuard":"def is_numeric_ea(dtype) -> bool:\n    import pandas as pd\n    return pd.api.types.is_numeric_dtype(dtype)","tryCatchPattern":"try:\n    s.cumsum()\nexcept NotImplementedError as e:\n    if \"cannot perform\" in str(e):\n        s.astype(\"Float64\").cumsum()\n    else:\n        raise","preventionTips":["Implement _accumulate on custom EA subclasses","Restrict cumulative reductions to numeric columns","Convert dtypes before cumulative ops"],"tags":["extension-array","accumulate","cumsum","not-implemented","subclass"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}