{"record":{"id":"fbbd3b589c7fd2a4","repo":"pola-rs/polars","slug":"functionality-for-nan-as-null-has-not-been-imple-fbbd3b","errorCode":null,"errorMessage":"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`.","messagePattern":"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`\\.","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"py-polars/src/polars/interchange/dataframe.py","lineNumber":64,"sourceCode":"        ----------\n        nan_as_null\n            Overwrite null values in the data with `NaN`.\n\n            .. warning::\n                This functionality has not been implemented and the parameter will be\n                removed in a future version.\n                Setting this to `True` will raise a `NotImplementedError`.\n        allow_copy\n            Allow memory to be copied to perform the conversion. If set to `False`,\n            causes conversions that are not zero-copy to fail.\n        \"\"\"\n        if nan_as_null:\n            msg = (\n                \"functionality for `nan_as_null` has not been implemented and the\"\n                \" parameter will be removed in a future version\"\n                \"\\n\\nUse the default `nan_as_null=False`.\"\n            )\n            raise NotImplementedError(msg)\n        return PolarsDataFrame(self._df, allow_copy=allow_copy)\n\n    @property\n    def metadata(self) -> dict[str, Any]:\n        \"\"\"The metadata for the dataframe.\"\"\"\n        return {}\n\n    def num_columns(self) -> int:\n        \"\"\"Return the number of columns in the dataframe.\"\"\"\n        return self._df.width\n\n    def num_rows(self) -> int:\n        \"\"\"Return the number of rows in the dataframe.\"\"\"\n        return self._df.height\n\n    def num_chunks(self) -> int:\n        \"\"\"\n        Return the number of chunks the dataframe consists of.","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/interchange/dataframe.py#L46-L82","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\ndf.__dataframe__(nan_as_null=True)\n// after\ndf.__dataframe__(nan_as_null=False)\n# NaN-as-null handled explicitly:\ndf = df.with_columns(pl.col(pl.Float64).fill_nan(None))","handlingStrategy":"validation","validationCode":"if nan_as_null:\n    df = df.with_columns(pl.col(pl.Float64).fill_nan(None))\n    nan_as_null = False  # then call __dataframe__(nan_as_null=False)","typeGuard":null,"tryCatchPattern":"try:\n    dfi = df.__dataframe__(nan_as_null=flag)\nexcept NotImplementedError:\n    dfi = df.__dataframe__(nan_as_null=False)","preventionTips":["Never pass nan_as_null=True; normalize NaN on the polars side instead","Upgrade consumers to interchange spec versions without the parameter"],"tags":["polars","interchange-protocol","nan","deprecated-parameter"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}