{"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":1921,"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":1903,"sourceCodeEnd":1939,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/arrow/array.py#L1903-L1939","documentation":"ArrowExtensionArray is backed by a 1D pyarrow.ChunkedArray, so the numpy-style reshape (which can change dimensionality) is structurally impossible. The reshape method is therefore unconditionally overridden to raise NotImplementedError. This is a hard API contract, not a runtime state.","triggerScenarios":"Calling .reshape(...) on a Series or ExtensionArray backed by an ArrowDtype (e.g. pd.array([1,2,3], dtype='int64[pyarrow]').reshape(3,1)) or any code path that delegates to ExtensionArray.reshape.","commonSituations":"Migrating numpy/ndarray code to pyarrow-backed pandas arrays; libraries (e.g. sklearn) that call reshape on inputs; reshaping a single Series for matrix operations.","solutions":["Convert to numpy first with .to_numpy().reshape(...) or np.asarray(arr).reshape(...), then wrap back if needed.","If 2D data is required, build a DataFrame or use a numpy-backed array (dtype='int64') instead of the pyarrow dtype.","Avoid calling reshape directly on ArrowExtensionArray instances."],"exampleFix":"// before\narr = pd.array([1, 2, 3, 4], dtype=\"int64[pyarrow]\")\narr.reshape(2, 2)\n// after\narr = pd.array([1, 2, 3, 4], dtype=\"int64[pyarrow]\")\nnp.asarray(arr).reshape(2, 2)","handlingStrategy":"validation","validationCode":"def safe_reshape(arr, shape):\n    import numpy as np\n    if hasattr(arr, \"_pa_array\"):  # ArrowExtensionArray\n        return np.asarray(arr).reshape(shape)\n    return arr.reshape(shape)","typeGuard":"from pandas.core.arrays.arrow import ArrowExtensionArray\n\ndef is_arrow_backed(arr) -> bool:\n    return isinstance(arr, ArrowExtensionArray)","tryCatchPattern":"try:\n    arr.reshape(shape)\nexcept NotImplementedError:\n    np.asarray(arr).reshape(shape)","preventionTips":["Always convert pyarrow-backed arrays to numpy with .to_numpy() before reshape.","Avoid passing ArrowExtensionArray instances to APIs that call reshape."],"tags":["pyarrow","reshape","notimplemented","extension-array"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}