{"record":{"id":"7f2a432e26b38a84","repo":"pandas-dev/pandas","slug":"operation-name-not-supported-for-dtype-self","errorCode":null,"errorMessage":"operation '{name}' not supported for dtype '{self.dtype}'","messagePattern":"operation '(.+?)' not supported for dtype '(.+?)'","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/arrow/array.py","lineNumber":2431,"sourceCode":"\n        convert_to_int = (\n            pa.types.is_temporal(pa_dtype) and name in [\"cummax\", \"cummin\"]\n        ) or (pa.types.is_duration(pa_dtype) and name == \"cumsum\")\n\n        if convert_to_int:\n            if pa_dtype.bit_width == 32:\n                data_to_accum = data_to_accum.cast(pa.int32())\n            else:\n                data_to_accum = data_to_accum.cast(pa.int64())\n\n        if name in (\"cummax\", \"cummin\") and pa.types.is_floating(data_to_accum.type):\n            kwargs[\"start\"] = float(\"-inf\") if name == \"cummax\" else float(\"inf\")\n\n        try:\n            result = pyarrow_meth(data_to_accum, skip_nulls=skipna, **kwargs)\n        except pa.ArrowNotImplementedError as err:\n            msg = f\"operation '{name}' not supported for dtype '{self.dtype}'\"\n            raise TypeError(msg) from err\n\n        if convert_to_int:\n            result = result.cast(pa_dtype)\n\n        return self._from_pyarrow_array(result)\n\n    def _str_accumulate(\n        self, name: str, *, skipna: bool = True, **kwargs\n    ) -> ArrowExtensionArray | ExtensionArray:\n        \"\"\"\n        Accumulate implementation for strings, see `_accumulate` docstring for details.\n\n        pyarrow.compute does not implement these methods for strings.\n        \"\"\"\n        if name == \"cumprod\":\n            msg = f\"operation '{name}' not supported for dtype '{self.dtype}'\"\n            raise TypeError(msg)\n","sourceCodeStart":2413,"sourceCodeEnd":2449,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/arrow/array.py#L2413-L2449","documentation":"Inside _accumulate, the requested reduction (cummax/cummin/cumsum/cumprod) is dispatched to pyarrow.compute. If pyarrow raises ArrowNotImplementedError (no kernel for this dtype, e.g. cumprod on strings), pandas re-raises it as a TypeError naming the unsupported operation and dtype. This is the fallback after dtype pre-handlers fail to cover the case.","triggerScenarios":"Calling .cumsum(), .cumprod(), .cummin(), or .cummax() on an ArrowExtensionArray whose pyarrow type lacks a matching accumulator kernel (e.g. cumprod on string[pyarrow], cumulative ops on some temporal types).","commonSituations":"Accidentally running cumulative reductions on categorical/string columns; pyarrow version missing a newer kernel.","solutions":["Check the column dtype and skip/convert non-numeric columns before applying cumulative reductions.","Upgrade pyarrow to a version that implements the kernel for this type.","Cast the column to a numeric dtype explicitly before .cumsum()/.cumprod()."],"exampleFix":"// before\ns = pd.Series([\"a\", \"b\"], dtype=\"string[pyarrow]\")\ns.cumsum()\n// after\ns = pd.Series([1, 2], dtype=\"int64[pyarrow]\")\ns.cumsum()","handlingStrategy":"try-catch","validationCode":"SUPPORTED_ACCUM = {\"cumsum\", \"cumprod\", \"cummin\", \"cummax\"}\nNUMERIC_KINDS = {\"i\", \"u\", \"f\", \"c\"}\n\ndef accum_supported(arr, name) -> bool:\n    return name in SUPPORTED_ACCUM and arr.dtype.kind in NUMERIC_KINDS","typeGuard":"def is_numeric_arrow(arr) -> bool:\n    return getattr(arr.dtype, \"kind\", \"\") in {\"i\", \"u\", \"f\", \"c\"}","tryCatchPattern":"try:\n    s.cumsum()\nexcept TypeError:\n    s.astype(\"float64\").cumsum()","preventionTips":["Filter DataFrame to numeric dtypes before applying cumulative reductions.","Upgrade pyarrow to pick up newer accumulator kernels."],"tags":["pyarrow","accumulate","cumsum","typeerror"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}