pola-rs/polars · error · NotImplementedError
functionality for `nan_as_null` has not been implemented and
Error message
functionality for `nan_as_null` has not been implemented and the parameter will be removed in a future version Use the default `nan_as_null=False`.
What it means
Raised by PolarsDataFrame.__dataframe__ when nan_as_null=True is passed. The parameter is declared for spec compatibility but its semantics (treating float NaN as null in the interchange layer) was never implemented; only the default False is accepted, and the parameter is slated for removal.
Source
Thrown at py-polars/src/polars/interchange/dataframe.py:64
----------
nan_as_null
Overwrite null values in the data with `NaN`.
.. warning::
This functionality has not been implemented and the parameter will be
removed in a future version.
Setting this to `True` will raise a `NotImplementedError`.
allow_copy
Allow memory to be copied to perform the conversion. If set to `False`,
causes conversions that are not zero-copy to fail.
"""
if nan_as_null:
msg = (
"functionality for `nan_as_null` has not been implemented and the"
" parameter will be removed in a future version"
"\n\nUse the default `nan_as_null=False`."
)
raise NotImplementedError(msg)
return PolarsDataFrame(self._df, allow_copy=allow_copy)
@property
def metadata(self) -> dict[str, Any]:
"""The metadata for the dataframe."""
return {}
def num_columns(self) -> int:
"""Return the number of columns in the dataframe."""
return self._df.width
def num_rows(self) -> int:
"""Return the number of rows in the dataframe."""
return self._df.height
def num_chunks(self) -> int:
"""
Return the number of chunks the dataframe consists of.View on GitHub (pinned to df599052da)
Solutions
- Call with nan_as_null=False (or omit it)
- If NaN-as-null semantics are needed, normalize on the polars side first: df.with_columns(pl.col(c).fill_nan(None) for float columns)
- Upgrade the consuming library to a version that no longer passes nan_as_null=True
Example fix
// before df.__dataframe__(nan_as_null=True) // after df.__dataframe__(nan_as_null=False) # NaN-as-null handled explicitly: df = df.with_columns(pl.col(pl.Float64).fill_nan(None))
Defensive patterns
Strategy: validation
Validate before calling
if nan_as_null:
df = df.with_columns(pl.col(pl.Float64).fill_nan(None))
nan_as_null = False # then call __dataframe__(nan_as_null=False) Try / catch
try:
dfi = df.__dataframe__(nan_as_null=flag)
except NotImplementedError:
dfi = df.__dataframe__(nan_as_null=False) Prevention
- Never pass nan_as_null=True; normalize NaN on the polars side instead
- Upgrade consumers to interchange spec versions without the parameter
When it happens
Trigger: Calling df.__dataframe__(nan_as_null=True); interchange consumers written against older dataframe-exchange drafts that default or pass nan_as_null=True; copy-pasted examples from legacy interchange tutorials.
Common situations: Upgrading libraries whose interchange integration predates the parameter's deprecation; consumers wanting NaN-as-null semantics for float columns; version drift between a consumer library and a newer polars.
Related errors
- bitmask must be constructed
- functionality for `nan_as_null` has not been implemented and
- non-contiguous buffer must be made contiguous
- __dlpack__
- `describe_categorical` only works on categorical columns
AI-assisted analysis of pola-rs/polars@df599052da (2026-08-16).
Data as JSON: /api/errors/fbbd3b589c7fd2a4.
Report an issue: GitHub.