{"record":{"id":"39f7f350a521086e","repo":"pola-rs/polars","slug":"expected-pyarrow-table-array-or-one-or-more-reco","errorCode":null,"errorMessage":"expected PyArrow Table, Array, or one or more RecordBatches; got {qualified_type_name(data)!r}","messagePattern":"expected PyArrow Table, Array, or one or more RecordBatches; got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/convert/general.py","lineNumber":607,"sourceCode":"        )\n\n    if isinstance(data, Iterable):\n        pa_table = pa.Table.from_batches(\n            itertools.chain.from_iterable(\n                (b.to_batches() if isinstance(b, pa.Table) else [b]) for b in data\n            )\n        )\n        return wrap_df(\n            arrow_to_pydf(\n                data=pa_table,\n                rechunk=rechunk,\n                schema=schema,\n                schema_overrides=schema_overrides,\n            )\n        )\n\n    msg = f\"expected PyArrow Table, Array, or one or more RecordBatches; got {qualified_type_name(data)!r}\"\n    raise TypeError(msg)\n\n\n@overload\ndef from_pandas(\n    data: pd.DataFrame,\n    *,\n    schema_overrides: SchemaDict | None = ...,\n    rechunk: bool = ...,\n    nan_to_null: bool = ...,\n    include_index: bool = ...,\n) -> DataFrame: ...\n\n\n@overload\ndef from_pandas(\n    data: pd.Series[Any] | pd.Index[Any] | pd.DatetimeIndex,\n    *,\n    schema_overrides: SchemaDict | None = ...,","sourceCodeStart":589,"sourceCodeEnd":625,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/convert/general.py#L589-L625","documentation":"`pl.from_arrow` converts PyArrow data (Table, Array, ChunkedArray, or RecordBatches) into a Polars DataFrame/Series. This TypeError is raised when the input `data` is none of those supported PyArrow types, so the conversion cannot proceed.","triggerScenarios":"Calling `pl.from_arrow(data)` with a pandas DataFrame, a plain dict/list, a numpy array, a string, None, or any object lacking Arrow data (no `__arrow_c_array__`/`__arrow_c_stream__` and not a pyarrow Table/Array/RecordBatch).","commonSituations":"Passing a pandas object to from_arrow instead of from_pandas; confusion between arrow-backed and native formats; passing the output of another library's loader (e.g. a Dask or DuckDB result) directly without converting to Arrow first.","solutions":["Convert the input to a pyarrow Table first: `pl.from_arrow(pa.table(obj))` or `pa.Table.from_pandas(df)`.","Use the correct converter for the type: `pl.from_pandas` for pandas, `pl.DataFrame(dict)` for dicts, `pl.from_dataframe` for objects exposing the Arrow PyCapsule Interface.","Check `isinstance(data, (pa.Table, pa.Array, pa.ChunkedArray, pa.RecordBatch))` before calling from_arrow."],"exampleFix":"// before\nimport polars as pl\npl.from_arrow(pandas_df)\n// after\nimport pyarrow as pa\npl.from_arrow(pa.Table.from_pandas(pandas_df))","handlingStrategy":"type-guard","validationCode":"import pyarrow as pa\nif not isinstance(data, (pa.Table, pa.Array, pa.ChunkedArray, pa.RecordBatch)):\n    data = pa.Table.from_pandas(data)  # or convert to arrow another way","typeGuard":"def is_arrow_data(x) -> bool:\n    import pyarrow as pa\n    return isinstance(x, (pa.Table, pa.Array, pa.ChunkedArray, pa.RecordBatch))","tryCatchPattern":"try:\n    df = pl.from_arrow(data)\nexcept TypeError:\n    df = pl.DataFrame(data)  # fallback for dict/list inputs","preventionTips":["Validate input type before conversion","Route by type: pandas -> from_pandas, dict -> DataFrame, arrow -> from_arrow","Prefer explicit conversion to pyarrow.Table at pipeline boundaries"],"tags":["python","polars","pyarrow","type-error"],"backgroundTag":"invalid-argument-value","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}