pandas-dev/pandas · error · ValueError
Unsupported type ' ' for ArrowExtensionArray
Error message
Unsupported type '{type(values)}' for ArrowExtensionArray What it means
Raised by ArrowExtensionArray.__init__ when the `values` argument is neither a pyarrow Array nor a pyarrow ChunkedArray. The constructor only accepts those two concrete pyarrow types so it can normalize the internal _pa_array field; any other object (numpy array, list, pandas Series, pandas Index, Python scalar) is rejected even if it is 'array-like'. Use the _from_sequence classmethod or pd.array(..., dtype='...[pyarrow]') to build from non-pyarrow inputs.
Solutions
- If you have a list/numpy array/Series, construct via the public path pd.array(data, dtype='<type>[pyarrow]') or cls._from_sequence(data, dtype=dtype) instead of cls(data).
- If you have a pyarrow object, ensure it is pa.Array or pa.ChunkedArray: wrap with pa.array(...) for an Array, or pa.chunked_array([...]) for a ChunkedArray.
- If you have a pa.RecordBatch or pa.Table, extract a column first with table.column(name) before constructing the extension array.
- Verify the type at runtime: isinstance(values, (pa.Array, pa.ChunkedArray)) before calling the constructor.
Example fix
# before import pyarrow as pa from pandas.core.arrays.arrow import ArrowExtensionArray arr = ArrowExtensionArray([1, 2, 3]) # raises ValueError # after arr = ArrowExtensionArray(pa.array([1, 2, 3])) # or the public path: arr = pd.array([1, 2, 3], dtype="int64[pyarrow]")
Defensive patterns
Strategy: type-guard
Validate before calling
import pyarrow as pa
def is_valid_arrow_input(values) -> bool:
return isinstance(values, (pa.Array, pa.ChunkedArray))
# usage
if not is_valid_arrow_input(values):
values = pa.array(values) Type guard
import pyarrow as pa
from typing import Any
def is_pa_array_or_chunked(v: Any) -> bool:
return isinstance(v, (pa.Array, pa.ChunkedArray)) Prevention
- Construct ArrowExtensionArray via pd.array(data, dtype='...[pyarrow]') or cls._from_sequence rather than the raw constructor.
- Keep a runtime isinstance check before passing values into the constructor.
- Document the accepted pyarrow types at every internal call site.
When it happens
Trigger: Calling ArrowExtensionArray(values) or ArrowStringArray(values) directly with a list, numpy.ndarray, pandas Series/Index, a pyarrow Scalar/Table/RecordBatch, or any object that is not an instance of pa.Array / pa.ChunkedArray. Also triggered indirectly when a subclass or internal helper passes an unconverted Python iterable into the constructor.
Common situations: Users constructing the extension array by hand instead of going through pd.array()/Series.astype('...[pyarrow]'); deserialization code that holds a numpy buffer; passing pa.array(...) is fine but passing the raw pa.scalar(...) or a tensor type is not; migration from numpy-backed extension arrays where the constructor accepted ndarrays.
Related errors
- Can only string multiply by an integer.
- DateOffset is intra-day and cannot be applied to…
- Invalid value ' ' for dtype
- __invert__ is not supported for string dtypes
- not implemented for
AI-assisted analysis of pandas-dev/pandas@3b7651241d (2026-08-11).
Data as JSON: /api/errors/d7e5227ab8c94dd5.
Report an issue: GitHub.
Appendix: source
Thrown at pandas/core/arrays/arrow/array.py:411
_pa_array: pa.ChunkedArray
_dtype: ArrowDtype
# results from calls to methods decorated with cache_readonly get added here
_cache: dict[str, pa.ChunkedArray]
def __init__(self, values: pa.Array | pa.ChunkedArray) -> None:
if not HAS_PYARROW:
msg = (
f"pyarrow>={PYARROW_MIN_VERSION} is required for PyArrow "
"backed ArrowExtensionArray."
)
raise ImportError(msg)
if isinstance(values, pa.Array):
self._pa_array = pa.chunked_array([values])
elif isinstance(values, pa.ChunkedArray):
self._pa_array = values
else:
raise ValueError(
f"Unsupported type '{type(values)}' for ArrowExtensionArray"
)
self._dtype = ArrowDtype(self._pa_array.type)
self._cache = {}
@classmethod
def _from_sequence(
cls, scalars, *, dtype: Dtype | None = None, copy: bool = False
) -> Self:
"""
Construct a new ExtensionArray from a sequence of scalars.
"""
pa_type = to_pyarrow_type(dtype)
pa_array = cls._box_pa_array(scalars, pa_type=pa_type, copy=copy)
arr = cls(pa_array)
return arr
@classmethodView on GitHub (pinned to 3b7651241d)