pola-rs/polars · error
pyarrow is required for converting a pandas dataframe to…
Error message
pyarrow is required for converting a pandas dataframe to Polars, unless each of its columns is a simple numpy-backed one (e.g. 'int64', 'bool', 'float32' - not 'Int64')
What it means
Raised by pandas_to_pydf when pyarrow is not installed and the pandas frame contains columns whose backing dtypes are not simple numpy types (e.g. pandas nullable 'Int64', string dtype, categoricals). Without pyarrow, polars can only convert plain numpy-backed columns and raises ImportError otherwise.
Solutions
- Install pyarrow: pip install pyarrow
- Cast extension dtypes to numpy equivalents before conversion, e.g. df = df.astype({'col': 'int64'})
- Use pl.from_pandas(df) only after ensuring all columns are numpy-backed, or convert column-by-column to polars Series
Example fix
// before pl.from_pandas(df) # df has pandas 'Int64' dtype, no pyarrow installed // after # pip install pyarrow pl.from_pandas(df)
Defensive patterns
Strategy: fallback
Validate before calling
import importlib.util
if importlib.util.find_spec('pyarrow') is None:
raise ImportError("pyarrow required for this pandas conversion; pip install pyarrow") Type guard
def pyarrow_available() -> bool:
import importlib.util
return importlib.util.find_spec('pyarrow') is not None Try / catch
try:
df_pl = pl.from_pandas(df)
except ImportError:
df_pl = pl.DataFrame({str(c): df[c].to_numpy() for c in df.columns}) Prevention
- Install the pandas extra: pip install 'polars[pandas]'
- Pin pyarrow in requirements/CI images
- Avoid pandas nullable extension dtypes ('Int64', 'boolean') on the hot conversion path, or cast to numpy dtypes first
When it happens
Trigger: pl.from_pandas(df) or pl.DataFrame(df) in an environment without pyarrow, where the frame has extension dtypes such as 'Int64', 'boolean', 'string', or datetime-with-timezone columns.
Common situations: Fresh virtualenv/CI image missing the pyarrow extra (pip install 'polars[pandas]'), pandas code migrated to nullable dtypes ('Int64') that used to convert fine, minimal deployments trimming dependencies.
Understand the failure class
Background: "not installed", "pip install", "required for": how missing-dependency errors surface across open-source libraries — this error's family across 34 libraries.
Related errors
- pandas>=1.5.0 is required for…
- pyarrow>=8.0.0 is required for…
- cannot parse Python data type
- `df` of type does not support the dataframe interchange…
- dimensions of columns arg must match data dimensions
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/1e51bb4672a1b8f4.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/_utils/construction/dataframe.py:1129
return PyDataFrame.empty_with_height(data.shape[0])
if all(is_simple_numpy_backed_pandas_series(data[col]) for col in data.columns):
# Convert via NumPy directly, no PyArrow needed.
return pl.DataFrame(
{str(col): data[col].to_numpy() for col in data.columns},
schema=schema,
strict=strict,
schema_overrides=schema_overrides,
nan_to_null=nan_to_null,
)._df
if not _PYARROW_AVAILABLE:
msg = (
"pyarrow is required for converting a pandas dataframe to Polars, "
"unless each of its columns is a simple numpy-backed one "
"(e.g. 'int64', 'bool', 'float32' - not 'Int64')"
)
raise ImportError(msg)
arrow_dict = {}
length = data.shape[0]
if convert_index:
for idxcol in data.index.names:
arrow_dict[str(idxcol)] = plc.pandas_series_to_arrow(
# get_level_values accepts `int | str`
# but `index.names` returns `Hashable`
data.index.get_level_values(idxcol), # type: ignore[arg-type, unused-ignore]
nan_to_null=nan_to_null,
length=length,
)
for col_idx, col_data in data.items():
arrow_dict[str(col_idx)] = plc.pandas_series_to_arrow(
col_data, nan_to_null=nan_to_null, length=length
)
View on GitHub (pinned to fe841f959e)