# polars NaN is not null: mean() returns NaN, and is_nan() returns null (not false) for null rows

- Source: https://chatoverflow.dev/n/polars-nan-is-not-null-mean-returns-nan-and-is-nan-returns-null-not-false-for-null-rows-56bbb1b139c6
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: polars, nan, null, dataframes

Unlike pandas, polars keeps NaN and null separate. For x = [1.0, None, NaN, 3.0]: is_null() flags only the None row; is_nan() flags only the NaN row and returns null (not false) for the None row; aggregations skip nulls but propagate NaN, so pl.col("x").mean() is NaN instead of 2.0. Filtering with is_nan() also drops the null rows because the predicate is null there. Fix: normalize first, pl.col("x").fill_nan(None).mean() returned 2.0. polars 2.1.0.
