{"record":{"id":"d1ecc0528735166c","repo":"pola-rs/polars","slug":"pyarrow-is-required-for-converting-a-pandas-series","errorCode":null,"errorMessage":"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')","messagePattern":"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'\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/_utils/construction/series.py","lineNumber":445,"sourceCode":"    dtype: PolarsDataType | None = None,\n    *,\n    strict: bool = True,\n    nan_to_null: bool = True,\n) -> PySeries:\n    \"\"\"Construct a PySeries from a pandas Series or DatetimeIndex.\"\"\"\n    if not name and values.name is not None:\n        name = str(values.name)\n    if is_simple_numpy_backed_pandas_series(values):\n        return pl.Series(\n            name, values.to_numpy(), dtype=dtype, nan_to_null=nan_to_null, strict=strict\n        )._s\n    if not _PYARROW_AVAILABLE:\n        msg = (\n            \"pyarrow is required for converting a pandas series to Polars, \"\n            \"unless it is a simple numpy-backed one \"\n            \"(e.g. 'int64', 'bool', 'float32' - not 'Int64')\"\n        )\n        raise ImportError(msg)\n    return arrow_to_pyseries(\n        name,\n        plc.pandas_series_to_arrow(values, nan_to_null=nan_to_null),\n        dtype=dtype,\n        strict=strict,\n    )\n\n\ndef arrow_to_pyseries(\n    name: str,\n    values: pa.Array,\n    dtype: PolarsDataType | None = None,\n    *,\n    strict: bool = True,\n    rechunk: bool = True,\n) -> PySeries:\n    \"\"\"Construct a PySeries from an Arrow array.\"\"\"\n    array = plc.coerce_arrow(values)","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/py-polars/src/polars/_utils/construction/series.py#L427-L463","documentation":"`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.","triggerScenarios":"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.","commonSituations":"Minimal installs without pyarrow; CI environments missing optional dependency; users using pandas nullable dtypes introduced in pandas 1.0+.","solutions":["Install pyarrow: pip install pyarrow (or polars with the pandas extra).","Convert the series to a simple numpy dtype first: series.astype('int64') (loses nullable semantics).","Pass series.to_numpy() to pl.Series for simple dtypes."],"exampleFix":"// before\npl.from_pandas(pandas_series_nullable_int)  # dtype Int64, no pyarrow\n// after\npip install pyarrow\n# or\npl.Series(pandas_series_nullable_int.to_numpy(dtype='int64'))","handlingStrategy":"fallback","validationCode":"if str(series.dtype) not in PANDAS_SIMPLE_NUMPY_DTYPES and not _PYARROW_AVAILABLE:\n    raise ImportError('pyarrow required for pandas extension dtype ' + str(series.dtype))","typeGuard":null,"tryCatchPattern":"try:\n    s = pl.from_pandas(series)\nexcept ImportError:\n    s = pl.Series(series.to_numpy())","preventionTips":["Declare pyarrow as a project dependency when using polars + pandas interchange.","Pin pyarrow in requirements/CI so extension dtypes always convert.","Prefer numpy-backed pandas dtypes when pyarrow is not available."],"tags":["polars","pandas","pyarrow","optional-dependency"],"backgroundTag":"missing-optional-dependency","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"}