{"record":{"id":"9a55bba848377260","repo":"pandas-dev/pandas","slug":"type-self-does-not-support-reshape-as-backed-by","errorCode":null,"errorMessage":"{type(self)} does not support reshape as backed by a 1D pyarrow.ChunkedArray.","messagePattern":"(.+?) does not support reshape as backed by a 1D pyarrow\\.ChunkedArray\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/arrow/array.py","lineNumber":1896,"sourceCode":"            indices = np.array([], dtype=np.intp)\n            uniques = self._from_pyarrow_array(\n                pa.chunked_array([], type=encoded.type.value_type)\n            )\n        else:\n            # GH 54844\n            combined = encoded.combine_chunks()\n            pa_indices = combined.indices\n            if pa_indices.null_count > 0:\n                pa_indices = _safe_fill_null(pa_indices, -1)\n            indices = pa_indices.to_numpy(zero_copy_only=False, writable=True).astype(\n                np.intp, copy=False\n            )\n            uniques = self._from_pyarrow_array(combined.dictionary)\n\n        return indices, uniques\n\n    def reshape(self, *args, **kwargs):\n        raise NotImplementedError(\n            f\"{type(self)} does not support reshape \"\n            f\"as backed by a 1D pyarrow.ChunkedArray.\"\n        )\n\n    def round(self, decimals: int = 0, *args, **kwargs) -> Self:\n        \"\"\"\n        Round each value in the array a to the given number of decimals.\n\n        Parameters\n        ----------\n        decimals : int, default 0\n            Number of decimal places to round to. If decimals is negative,\n            it specifies the number of positions to the left of the decimal point.\n        *args, **kwargs\n            Additional arguments and keywords have no effect.\n\n        Returns\n        -------","sourceCodeStart":1878,"sourceCodeEnd":1914,"githubUrl":"https://github.com/pandas-dev/pandas/blob/71959b8cb9b2459c16e14b34f28b178ccfe14735/pandas/core/arrays/arrow/array.py#L1878-L1914","documentation":"ArrowExtensionArray.reshape unconditionally raises NotImplementedError. The backing storage is a 1D pyarrow.ChunkedArray, which has no native concept of multi-dimensional shape, so reshape semantics cannot be honored.","triggerScenarios":"Calling `.reshape(...)` directly on an ArrowExtensionArray instance, or via numpy/pandas code paths that dispatch reshape to the ExtensionArray.","commonSituations":"Porting numpy ndarray code to pyarrow dtypes, calling `arr.values.reshape(...)` on a Series, or libraries that expect ndarray-like reshape on arbitrary array objects.","solutions":["Materialize to a numpy array first: `arr.to_numpy().reshape(...)` (note: this may copy and lose pyarrow-specific types like decimal).","If you need a 2D DataFrame view, construct it explicitly with the desired columns instead of reshaping.","Switch the dtype away from `[pyarrow]` if reshape is a core requirement."],"exampleFix":"// before\narr = pd.array([1, 2, 3, 4], dtype=\"int64[pyarrow]\")\narr.reshape(2, 2)\n\n// after\narr.to_numpy().reshape(2, 2)","handlingStrategy":"validation","validationCode":"def safe_reshape(arr, *shape):\n    # ArrowExtensionArray cannot reshape; materialize to numpy first\n    return arr.to_numpy().reshape(*shape)","typeGuard":"def supports_reshape(arr) -> bool:\n    # pyarrow-backed ExtensionArrays never support reshape\n    import pandas as pd\n    return not isinstance(getattr(arr, \"dtype\", None), pd.ArrowDtype)","tryCatchPattern":"try:\n    arr.reshape(2, 2)\nexcept NotImplementedError as e:\n    if \"does not support reshape\" in str(e):\n        out = arr.to_numpy().reshape(2, 2)\n    else:\n        raise","preventionTips":["Do not call reshape on pyarrow-backed arrays; materialize to numpy first.","In generic code, branch on dtype family before reshape.","Document reshape limitations when migrating code from numpy ndarray to arrow dtypes."],"tags":["arrow","reshape","not-implemented","numpy-interop"],"analyzedSha":"71959b8cb9b2459c16e14b34f28b178ccfe14735","analyzedAt":"2026-08-07T01:30:20.476Z","schemaVersion":2},"datasetVersion":"2026-08-07T03:17:09.362Z"}