pola-rs/polars · error · ModuleUpgradeRequiredError
pandas>=1.5.0 is required for…
Error message
pandas>=1.5.0 is required for `to_pandas("use_pyarrow_extension_array=True")`, found Pandas {pd.__version__} What it means
to_pandas(use_pyarrow_extension_array=True) relies on pandas' ArrowDtype-backed extension arrays, introduced in pandas 1.5.0. If the installed pandas is older, polars raises ModuleUpgradeRequiredError with the detected version.
Solutions
- Upgrade pandas: pip install -U 'pandas>=1.5.0'
- Call to_pandas() without use_pyarrow_extension_array
- Convert via numpy only: pd.Series(srs.to_numpy())
Example fix
// before srs.to_pandas(use_pyarrow_extension_array=True) // after # either upgrade pandas>=1.5.0, or: srs.to_pandas()
Defensive patterns
Strategy: validation
Validate before calling
from polars.dependencies import pandas as pd from polars.utils.various import parse_version assert parse_version(pd.__version__) >= (1, 5), 'pandas>=1.5.0 required'
Try / catch
try:
pdf = srs.to_pandas(use_pyarrow_extension_array=True)
except pl.exceptions.ModuleUpgradeRequiredError:
pdf = srs.to_pandas() Prevention
- Pin pandas>=1.5.0 in requirements when using arrow extension arrays
- Check pd.__version__ at startup in legacy environments
- Use plain to_pandas() if arrow-backed dtypes are not needed
When it happens
Trigger: srs.to_pandas(use_pyarrow_extension_array=True) with pandas < 1.5.0 installed (e.g. pandas 1.3/1.4 in pinned environments).
Common situations: Legacy environments (older conda pins, air-gapped installs) where pandas cannot be upgraded; CI images with stale pandas.
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
- pyarrow>=8.0.0 is required for…
- pyarrow is required for converting a pandas dataframe to…
- `df` of type does not support the dataframe interchange…
- pyarrow is required for converting a pandas series to…
- cannot parse Python data type
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/ad61452bb56bc078.
Report an issue: GitHub.
Appendix: source
Thrown at py-polars/src/polars/series/series.py:5296
Name: b, dtype: float64
Pass `use_pyarrow_extension_array=True` to get a pandas Series backed by a
PyArrow extension array. This will preserve null values.
>>> s.to_pandas(use_pyarrow_extension_array=True)
0 1
1 2
2 <NA>
Name: b, dtype: int64[pyarrow]
"""
if self.dtype == Object:
# Can't convert via PyArrow, so do it via NumPy
return pd.Series(self.to_numpy(), dtype=object, name=self.name)
if use_pyarrow_extension_array:
if parse_version(pd.__version__) < (1, 5):
msg = f'pandas>=1.5.0 is required for `to_pandas("use_pyarrow_extension_array=True")`, found Pandas {pd.__version__}'
raise ModuleUpgradeRequiredError(msg)
if not _PYARROW_AVAILABLE or parse_version(pa.__version__) < (8, 0):
raise ModuleUpgradeRequiredError(
f'pyarrow>=8.0.0 is required for `to_pandas("use_pyarrow_extension_array=True")`'
f", found pyarrow {pa.__version__!r}"
if _PYARROW_AVAILABLE
else ""
)
if isinstance(self.dtype, (Categorical, Enum)):
return (
self.to_frame()
.to_pandas(
use_pyarrow_extension_array=use_pyarrow_extension_array, **kwargs
)
.iloc[:, 0]
)
else:
pa_arr = self.to_arrow()View on GitHub (pinned to fe841f959e)