{"record":{"id":"d7e5227ab8c94dd5","repo":"pandas-dev/pandas","slug":"unsupported-type-type-values-for-arrowextensi","errorCode":null,"errorMessage":"Unsupported type '{type(values)}' for ArrowExtensionArray","messagePattern":"Unsupported type '(.+?)' for ArrowExtensionArray","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"pandas/core/arrays/arrow/array.py","lineNumber":411,"sourceCode":"\n    _pa_array: pa.ChunkedArray\n    _dtype: ArrowDtype\n    # results from calls to methods decorated with cache_readonly get added here\n    _cache: dict[str, pa.ChunkedArray]\n\n    def __init__(self, values: pa.Array | pa.ChunkedArray) -> None:\n        if not HAS_PYARROW:\n            msg = (\n                f\"pyarrow>={PYARROW_MIN_VERSION} is required for PyArrow \"\n                \"backed ArrowExtensionArray.\"\n            )\n            raise ImportError(msg)\n        if isinstance(values, pa.Array):\n            self._pa_array = pa.chunked_array([values])\n        elif isinstance(values, pa.ChunkedArray):\n            self._pa_array = values\n        else:\n            raise ValueError(\n                f\"Unsupported type '{type(values)}' for ArrowExtensionArray\"\n            )\n        self._dtype = ArrowDtype(self._pa_array.type)\n        self._cache = {}\n\n    @classmethod\n    def _from_sequence(\n        cls, scalars, *, dtype: Dtype | None = None, copy: bool = False\n    ) -> Self:\n        \"\"\"\n        Construct a new ExtensionArray from a sequence of scalars.\n        \"\"\"\n        pa_type = to_pyarrow_type(dtype)\n        pa_array = cls._box_pa_array(scalars, pa_type=pa_type, copy=copy)\n        arr = cls(pa_array)\n        return arr\n\n    @classmethod","sourceCodeStart":393,"sourceCodeEnd":429,"githubUrl":"https://github.com/pandas-dev/pandas/blob/3b7651241d4da534b3559b60ef128e1c34f54116/pandas/core/arrays/arrow/array.py#L393-L429","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nimport pyarrow as pa\nfrom pandas.core.arrays.arrow import ArrowExtensionArray\narr = ArrowExtensionArray([1, 2, 3])  # raises ValueError\n\n# after\narr = ArrowExtensionArray(pa.array([1, 2, 3]))\n# or the public path:\narr = pd.array([1, 2, 3], dtype=\"int64[pyarrow]\")","handlingStrategy":"type-guard","validationCode":"import pyarrow as pa\n\ndef is_valid_arrow_input(values) -> bool:\n    return isinstance(values, (pa.Array, pa.ChunkedArray))\n\n# usage\nif not is_valid_arrow_input(values):\n    values = pa.array(values)","typeGuard":"import pyarrow as pa\nfrom typing import Any\n\ndef is_pa_array_or_chunked(v: Any) -> bool:\n    return isinstance(v, (pa.Array, pa.ChunkedArray))","tryCatchPattern":null,"preventionTips":["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."],"tags":["pyarrow","constructor","type-validation","extension-array"],"backgroundTag":null,"analyzedSha":"3b7651241d4da534b3559b60ef128e1c34f54116","analyzedAt":"2026-08-11T22:10:44.015Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}