pandas-dev/pandas · error · NotImplementedError
does not support reshape as backed by a 1D…
Error message
{type(self)} does not support reshape as backed by a 1D pyarrow.ChunkedArray. What it means
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.
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.
Example fix
// before arr = pd.array([1, 2, 3, 4], dtype="int64[pyarrow]") arr.reshape(2, 2) // after arr = pd.array([1, 2, 3, 4], dtype="int64[pyarrow]") np.asarray(arr).reshape(2, 2)
Defensive patterns
Strategy: validation
Validate before calling
def safe_reshape(arr, shape):
import numpy as np
if hasattr(arr, "_pa_array"): # ArrowExtensionArray
return np.asarray(arr).reshape(shape)
return arr.reshape(shape) Type guard
from pandas.core.arrays.arrow import ArrowExtensionArray
def is_arrow_backed(arr) -> bool:
return isinstance(arr, ArrowExtensionArray) Try / catch
try:
arr.reshape(shape)
except NotImplementedError:
np.asarray(arr).reshape(shape) Prevention
- Always convert pyarrow-backed arrays to numpy with .to_numpy() before reshape.
- Avoid passing ArrowExtensionArray instances to APIs that call reshape.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Converting strings to
- groupby first/last only supports 1D ExtensionArrays
- interpolate is not implemented for dtype=
- {pa_type}
- Unsupported type ' ' for ArrowExtensionArray
AI-assisted analysis of pandas-dev/pandas@3b7651241d (2026-08-11).
Data as JSON: /api/errors/9a55bba848377260.
Report an issue: GitHub.
Appendix: source
Thrown at pandas/core/arrays/arrow/array.py:1921
indices = np.array([], dtype=np.intp)
uniques = self._from_pyarrow_array(
pa.chunked_array([], type=encoded.type.value_type)
)
else:
# GH 54844
combined = encoded.combine_chunks()
pa_indices = combined.indices
if pa_indices.null_count > 0:
pa_indices = _safe_fill_null(pa_indices, -1)
indices = pa_indices.to_numpy(zero_copy_only=False, writable=True).astype(
np.intp, copy=False
)
uniques = self._from_pyarrow_array(combined.dictionary)
return indices, uniques
def reshape(self, *args, **kwargs):
raise NotImplementedError(
f"{type(self)} does not support reshape "
f"as backed by a 1D pyarrow.ChunkedArray."
)
def round(self, decimals: int = 0, *args, **kwargs) -> Self:
"""
Round each value in the array a to the given number of decimals.
Parameters
----------
decimals : int, default 0
Number of decimal places to round to. If decimals is negative,
it specifies the number of positions to the left of the decimal point.
*args, **kwargs
Additional arguments and keywords have no effect.
Returns
-------View on GitHub (pinned to 3b7651241d)