{"record":{"id":"3d0611b48356b510","repo":"pandas-dev/pandas","slug":"type-self-name-with-dtype-self-dtype-do","errorCode":null,"errorMessage":"'{type(self).__name__}' with dtype {self.dtype} does not support operation '{name}'","messagePattern":"'(.+?)' with dtype (.+?) does not support operation '(.+?)'","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/arrow/array.py","lineNumber":2599,"sourceCode":"                )[0]\n                return pc.binary_join(data_list, \"\")\n        elif name in [\"argmin\", \"argmax\"]:\n            return super()._reduce(name, skipna=skipna, **kwargs)\n\n        else:\n            pyarrow_name = {\n                \"median\": \"quantile\",\n                \"prod\": \"product\",\n                \"std\": \"stddev\",\n                \"var\": \"variance\",\n                \"kurt\": \"kurtosis\",\n            }.get(name, name)\n            # error: Incompatible types in assignment\n            # (expression has type \"Optional[Any]\", variable has type\n            # \"Callable[[Any, Any, KwArg(Any)], Any]\")\n            pyarrow_meth = getattr(pc, pyarrow_name, None)  # type: ignore[assignment]\n            if pyarrow_meth is None:\n                raise TypeError(\n                    f\"'{type(self).__name__}' with dtype {self.dtype} \"\n                    f\"does not support operation '{name}'\"\n                )\n\n        # GH51624: pyarrow defaults to min_count=1, pandas behavior is min_count=0\n        if name in [\"any\", \"all\", \"sum\", \"prod\"] and \"min_count\" not in kwargs:\n            kwargs[\"min_count\"] = 0\n        elif name == \"median\":\n            # GH 52679: Use quantile instead of approximate_median\n            kwargs[\"q\"] = 0.5\n        elif name in [\"std\", \"var\", \"sem\"] and \"ddof\" not in kwargs:\n            # pyarrow defaults to ddof=0, pandas behavior is ddof=1\n            kwargs[\"ddof\"] = 1\n        elif name in [\"skew\", \"kurt\"] and \"biased\" not in kwargs:\n            kwargs[\"biased\"] = False\n\n        try:\n            result = pyarrow_meth(data_to_reduce, skip_nulls=skipna, **kwargs)","sourceCodeStart":2581,"sourceCodeEnd":2617,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/arrow/array.py#L2581-L2617","documentation":"In _reduce, the requested reduction name is mapped to a pyarrow.compute function (median->quantile, std->stddev, etc.). If getattr(pc, name, None) returns None, the pyarrow function genuinely does not exist for any type, so pandas raises TypeError listing the array class, dtype, and unsupported operation. This fires before any data is processed.","triggerScenarios":"Calling a reduction like .kurt() on a dtype where pandas has no pyarrow-compute mapping (e.g. .median() on some types in older pyarrow, or unsupported methods like rank via this path), or any custom reduction routed through _reduce without a pc equivalent.","commonSituations":"Calling statistical reductions not yet supported by the installed pyarrow; generic reduce-by-name dispatch in user code.","solutions":["Upgrade pyarrow to a version that implements the function.","Cast to a numpy-backed dtype (e.g. .astype('float64')) and apply the reduction there.","Confirm the reduction name is in the supported set for this dtype before calling."],"exampleFix":"// before\ns = pd.Series([1, 2, 3], dtype=\"int64[pyarrow]\")\ns.<unsupported_reduce>()\n// after\ns = pd.Series([1, 2, 3], dtype=\"int64[pyarrow]\")\ns.astype(\"float64\").<unsupported_reduce>()","handlingStrategy":"try-catch","validationCode":"import pyarrow.compute as pc\n\ndef reduce_available(name) -> bool:\n    alias = {\"median\":\"quantile\",\"prod\":\"product\",\"std\":\"stddev\",\"var\":\"variance\",\"kurt\":\"kurtosis\"}.get(name, name)\n    return getattr(pc, alias, None) is not None","typeGuard":"def arrow_reduce_supported(name) -> bool:\n    import pyarrow.compute as pc\n    return getattr(pc, name, None) is not None","tryCatchPattern":"try:\n    s.<reduce>()\nexcept TypeError:\n    s.astype(\"float64\").<reduce>()","preventionTips":["Check pyarrow.compute for the function name before dispatching reductions.","Keep a numpy fallback path for reductions missing in pyarrow."],"tags":["pyarrow","reduce","typeerror","version"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}