pola-rs/polars · error

pyarrow is required for converting a pandas series to…

Error message

pyarrow is required for converting a pandas series to Polars, unless it is a simple numpy-backed one (e.g. 'int64', 'bool', 'float32' - not 'Int64')

What it means

`pandas_to_pyseries` converts pandas Series via pyarrow unless the series is a simple numpy-backed dtype that can go directly through numpy. Without pyarrow installed, any non-simple pandas dtype (e.g. pandas nullable Int64, categorical, datetime with tz) raises ImportError.

Solutions

  1. Install pyarrow: pip install pyarrow (or polars with the pandas extra).
  2. Convert the series to a simple numpy dtype first: series.astype('int64') (loses nullable semantics).
  3. Pass series.to_numpy() to pl.Series for simple dtypes.

Example fix

// before
pl.from_pandas(pandas_series_nullable_int)  # dtype Int64, no pyarrow
// after
pip install pyarrow
# or
pl.Series(pandas_series_nullable_int.to_numpy(dtype='int64'))
Defensive patterns

Strategy: fallback

Validate before calling

if str(series.dtype) not in PANDAS_SIMPLE_NUMPY_DTYPES and not _PYARROW_AVAILABLE:
    raise ImportError('pyarrow required for pandas extension dtype ' + str(series.dtype))

Try / catch

try:
    s = pl.from_pandas(series)
except ImportError:
    s = pl.Series(series.to_numpy())

Prevention

When it happens

Trigger: Calling pl.from_pandas(series) or pl.Series(series) on a pandas Series with extension dtype (Int64, Float64 nullable, string[python], categorical) while pyarrow is not installed.

Common situations: Minimal installs without pyarrow; CI environments missing optional dependency; users using pandas nullable dtypes introduced in pandas 1.0+.

Understand the failure class

Background: "X is not installed. Please install it with pip install Y": missing optional dependency errors — ImportError/ValueError raised when a library's optional extra was never installed — this error's family across 22 libraries.

Related errors


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

Appendix: source

Thrown at py-polars/src/polars/_utils/construction/series.py:445

    dtype: PolarsDataType | None = None,
    *,
    strict: bool = True,
    nan_to_null: bool = True,
) -> PySeries:
    """Construct a PySeries from a pandas Series or DatetimeIndex."""
    if not name and values.name is not None:
        name = str(values.name)
    if is_simple_numpy_backed_pandas_series(values):
        return pl.Series(
            name, values.to_numpy(), dtype=dtype, nan_to_null=nan_to_null, strict=strict
        )._s
    if not _PYARROW_AVAILABLE:
        msg = (
            "pyarrow is required for converting a pandas series to Polars, "
            "unless it is a simple numpy-backed one "
            "(e.g. 'int64', 'bool', 'float32' - not 'Int64')"
        )
        raise ImportError(msg)
    return arrow_to_pyseries(
        name,
        plc.pandas_series_to_arrow(values, nan_to_null=nan_to_null),
        dtype=dtype,
        strict=strict,
    )


def arrow_to_pyseries(
    name: str,
    values: pa.Array,
    dtype: PolarsDataType | None = None,
    *,
    strict: bool = True,
    rechunk: bool = True,
) -> PySeries:
    """Construct a PySeries from an Arrow array."""
    array = plc.coerce_arrow(values)

View on GitHub (pinned to fe841f959e)