{"record":{"id":"f0e48b902162ad9b","repo":"pola-rs/polars","slug":"functionality-for-nan-as-null-has-not-been-imple","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/dataframe/frame.py","lineNumber":1086,"sourceCode":"        Examples\n        --------\n        Convert a Polars DataFrame to a generic dataframe object and access some\n        properties.\n\n        >>> df = pl.DataFrame({\"a\": [1, 2], \"b\": [3.0, 4.0], \"c\": [\"x\", \"y\"]})\n        >>> dfi = df.__dataframe__()  # doctest: +SKIP\n        >>> dfi.num_rows()  # doctest: +SKIP\n        2\n        >>> dfi.get_column(1).dtype  # doctest: +SKIP\n        (<DtypeKind.FLOAT: 2>, 64, 'g', '=')\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\n        from polars.interchange.dataframe import PolarsDataFrame\n\n        return PolarsDataFrame(self, allow_copy=allow_copy)\n\n    def _comp(self, other: Any, op: ComparisonOperator) -> DataFrame:\n        \"\"\"Compare a DataFrame with another object.\"\"\"\n        if isinstance(other, DataFrame):\n            return self._compare_to_other_df(other, op)\n        else:\n            return self._compare_to_non_df(other, op)\n\n    def _compare_to_other_df(\n        self,\n        other: DataFrame,\n        op: ComparisonOperator,\n    ) -> DataFrame:\n        \"\"\"Compare a DataFrame with another DataFrame.\"\"\"","sourceCodeStart":1068,"sourceCodeEnd":1104,"githubUrl":"https://github.com/pola-rs/polars/blob/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/py-polars/src/polars/dataframe/frame.py#L1068-L1104","documentation":"The dataframe interchange protocol's nan_as_null=True semantics (mapping NaN to null during interchange) were never implemented in polars, and the parameter is slated for removal from the protocol. DataFrame.__dataframe__ therefore raises NotImplementedError whenever anything but the default False is passed, instead of returning incorrect null semantics.","triggerScenarios":"df.__dataframe__(nan_as_null=True) called directly; an interchange consumer library (older versions of dataframe protocol clients, some plotting/validation tools) passing nan_as_null=True explicitly; wrapper code forwarding user kwargs into __dataframe__.","commonSituations":"Third-party libs written against early interchange-protocol drafts; upgrade scripts that set the flag 'for safety' and thereby break every float frame containing NaN; testing harnesses enumerating all protocol parameters.","solutions":["Call with the default: df.__dataframe__() or df.__dataframe__(allow_copy=...)","If a consumer insists on nan-as-null, convert in polars first: df.with_columns(pl.col(pl.Float64).fill_nan(None)) then interchange without the flag","Upgrade the consumer library to a version that no longer passes nan_as_null"],"exampleFix":"# before\ninterchange_object = df.__dataframe__(nan_as_null=True)\n\n# after\ndf = df.with_columns(pl.col(pl.Float64).fill_nan(None))\ninterchange_object = df.__dataframe__()","handlingStrategy":"validation","validationCode":"if nan_as_null:\n    df = df.with_columns(pl.col(pl.Float64).fill_nan(None))\n    nan_as_null = False  # use protocol default afterwards\ndfi = df.__dataframe__(allow_copy=allow_copy)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass nan_as_null to __dataframe__; the default False is the only supported mode","Do fill_nan(None) in polars when null-instead-of-NaN semantics are required","Keep interchange consumers up to date; newer protocol versions dropped the parameter"],"tags":["interchange-protocol","nan","not-implemented","interop"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}