pola-rs/polars · error

expected PyArrow Table, Array, or one or more…

Error message

expected PyArrow Table, Array, or one or more RecordBatches; got {qualified_type_name(data)!r}

What it means

`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.

Solutions

  1. Convert the input to a pyarrow Table first: `pl.from_arrow(pa.table(obj))` or `pa.Table.from_pandas(df)`.
  2. 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.
  3. Check `isinstance(data, (pa.Table, pa.Array, pa.ChunkedArray, pa.RecordBatch))` before calling from_arrow.

Example fix

// before
import polars as pl
pl.from_arrow(pandas_df)
// after
import pyarrow as pa
pl.from_arrow(pa.Table.from_pandas(pandas_df))
Defensive patterns

Strategy: type-guard

Validate before calling

import pyarrow as pa
if not isinstance(data, (pa.Table, pa.Array, pa.ChunkedArray, pa.RecordBatch)):
    data = pa.Table.from_pandas(data)  # or convert to arrow another way

Type guard

def is_arrow_data(x) -> bool:
    import pyarrow as pa
    return isinstance(x, (pa.Table, pa.Array, pa.ChunkedArray, pa.RecordBatch))

Try / catch

try:
    df = pl.from_arrow(data)
except TypeError:
    df = pl.DataFrame(data)  # fallback for dict/list inputs

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18). Data as JSON: /api/errors/39f7f350a521086e. Report an issue: GitHub.

Appendix: source

Thrown at py-polars/src/polars/convert/general.py:607

        )

    if isinstance(data, Iterable):
        pa_table = pa.Table.from_batches(
            itertools.chain.from_iterable(
                (b.to_batches() if isinstance(b, pa.Table) else [b]) for b in data
            )
        )
        return wrap_df(
            arrow_to_pydf(
                data=pa_table,
                rechunk=rechunk,
                schema=schema,
                schema_overrides=schema_overrides,
            )
        )

    msg = f"expected PyArrow Table, Array, or one or more RecordBatches; got {qualified_type_name(data)!r}"
    raise TypeError(msg)


@overload
def from_pandas(
    data: pd.DataFrame,
    *,
    schema_overrides: SchemaDict | None = ...,
    rechunk: bool = ...,
    nan_to_null: bool = ...,
    include_index: bool = ...,
) -> DataFrame: ...


@overload
def from_pandas(
    data: pd.Series[Any] | pd.Index[Any] | pd.DatetimeIndex,
    *,
    schema_overrides: SchemaDict | None = ...,

View on GitHub (pinned to fe841f959e)