{"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":"validation","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/arrow/array.py","lineNumber":2406,"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":2388,"sourceCodeEnd":2424,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/arrays/arrow/array.py#L2388-L2424","documentation":"Raised in _accumulate when pyarrow.compute raises ArrowNotImplementedError while computing a cumulative operation (cumsum/cummax/cummin/cumprod). pandas wraps it as a TypeError naming the unsupported dtype so users get a clear, dtype-specific failure.","triggerScenarios":"Calling `Series.cumsum/cumprod/cummax/cummin` on a pyarrow-backed Series whose dtype has no pyarrow kernel — e.g. `cumsum` on a `duration[ns][pyarrow]` Series, or `cumprod` on most non-float dtypes.","commonSituations":"Using cumulative reductions on temporal/duration/decimal/string arrow columns, or assuming numpy-style cumsum works uniformly across all dtypes.","solutions":["Cast to a numeric dtype that supports the operation: `s.astype(\"int64[pyarrow]\").cumsum()`.","Pick a different accumulation method that is supported for the dtype (e.g. cummax/cummin for temporal types).","If you need cumprod on integers, the operation is unsupported in pyarrow; compute it via numpy instead."],"exampleFix":"// before\ns = pd.Series([1, 2, 3], dtype=\"duration[ns][pyarrow]\")\ns.cumsum()\n\n// after\ns.astype(\"int64[pyarrow]\").cumsum()","handlingStrategy":"validation","validationCode":"SUPPORTED_CUMULATIVE = {\"cumsum\": {\"int\", \"float\"}, \"cumprod\": {\"float\"}, \"cummax\": {\"int\", \"float\", \"temporal\"}, \"cummin\": {\"int\", \"float\", \"temporal\"}}\n\ndef can_accumulate(arr, name) -> bool:\n    kind = getattr(arr.dtype, \"kind\", None)\n    families = {\"int\" if kind in \"iu\" else \"float\" if kind == \"f\" else \"temporal\" if kind in \"mM\" else None}\n    return any(f in SUPPORTED_CUMULATIVE.get(name, set()) for f in families if f)","typeGuard":"def supports_cumulative(arr, name) -> bool:\n    # conservative check; final answer is pyarrow's kernel availability\n    try:\n        import pyarrow.compute as pc\n        return getattr(pc, name, None) is not None\n    except Exception:\n        return False","tryCatchPattern":"try:\n    s.cumsum()\nexcept TypeError as e:\n    if \"not supported for dtype\" in str(e):\n        s.astype(\"int64[pyarrow]\").cumsum()\n    else:\n        raise","preventionTips":["Check dtype.kind before applying cumulative reductions.","Keep a list of dtype-supported accumulations per column in ETL metadata.","Cast temporal/duration columns to int representation before numeric cum ops."],"tags":["arrow","accumulate","cumsum","dtype","pyarrow"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}