{"record":{"id":"cbf495839c857683","repo":"pandas-dev/pandas","slug":"pa-type","errorCode":null,"errorMessage":"{pa_type}","messagePattern":"\\{pa_type\\}","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/arrow/array.py","lineNumber":3133,"sourceCode":"        Parameters\n        ----------\n        dropna : bool, default True\n            Don't consider counts of NA values.\n\n        Returns\n        -------\n        same type as self\n            Sorted, if possible.\n        \"\"\"\n        pa_type = self._pa_array.type\n        if pa.types.is_temporal(pa_type):\n            nbits = pa_type.bit_width\n            if nbits == 32:\n                data = self._pa_array.cast(pa.int32())\n            elif nbits == 64:\n                data = self._pa_array.cast(pa.int64())\n            else:\n                raise NotImplementedError(pa_type)\n        else:\n            data = self._pa_array\n\n        if dropna:\n            data = data.drop_null()\n\n        res = pc.value_counts(data)\n        most_common = res.field(\"values\").filter(\n            pc.equal(res.field(\"counts\"), pc.max(res.field(\"counts\")))\n        )\n\n        if pa.types.is_temporal(pa_type):\n            most_common = most_common.cast(pa_type)\n\n        most_common = most_common.take(pc.array_sort_indices(most_common))\n        return self._from_pyarrow_array(most_common)\n\n    def _validate_setitem_value(self, value):","sourceCodeStart":3115,"sourceCodeEnd":3151,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/arrow/array.py#L3115-L3151","documentation":"In _mode, temporal pyarrow types are cast to int32 (32-bit) or int64 (64-bit) before value_counts. The branch explicitly raises NotImplementedError(pa_type) for any other temporal bit width. As of writing, pyarrow only produces 32- and 64-bit temporal types, so this is a forward-compatible guard against new pyarrow temporal widths (e.g. a future narrower date/time type).","triggerScenarios":"Computing .mode() on an ArrowExtensionArray whose pyarrow type is temporal with a bit_width other than 32 or 64 (currently not producible by stock pyarrow).","commonSituations":"Future pyarrow release introducing a new temporal width; custom pyarrow extension types registered as temporal.","solutions":["Cast the column to a standard 64-bit temporal dtype (e.g. timestamp[ns]) before calling .mode().","Upgrade or downgrade pyarrow to a version whose temporal types are 32/64-bit only.","Compute mode manually via .value_counts() after casting to int64."],"exampleFix":"// before\ns = pd.Series([...], dtype=\"timestamp[unit][pyarrow]\")  # exotic width\ns.mode()\n// after\ns = s.astype(\"timestamp[ns][pyarrow]\")\ns.mode()","handlingStrategy":"try-catch","validationCode":"import pyarrow as pa\n\ndef mode_supported(arr) -> bool:\n    t = arr._pa_array.type\n    if pa.types.is_temporal(t):\n        return t.bit_width in (32, 64)\n    return True","typeGuard":"import pyarrow as pa\n\ndef is_standard_temporal(arr) -> bool:\n    t = arr._pa_array.type\n    return not pa.types.is_temporal(t) or t.bit_width in (32, 64)","tryCatchPattern":"try:\n    s.mode()\nexcept NotImplementedError:\n    s.astype(\"timestamp[ns][pyarrow]\").mode()","preventionTips":["Use 64-bit temporal dtypes for downstream statistics.","Cast exotic temporal types to timestamp[ns] before .mode()."],"tags":["pyarrow","mode","temporal","notimplemented"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}