5

I'm trying to replace Pandas with Polars in production code, for better memory performance.

What would be the Polars equivalent of Pandas .isna() method? I couldn't find any good equivalent in the doc.

bolino
  • 867
  • 1
  • 10
  • 27
  • 3
    Note the distinction between missing values and floating point `NaN` values. Missing values is likely the one you'll be needing most. That is `is_null` and floating point `NaN` is `is_nan`. – ritchie46 Nov 25 '21 at 15:46

1 Answers1

4

Polars has .is_null(). Note that Pandas has .isnull() as well, which is an alias for .isna().

I.e., per the example linked above:

s = pl.Series("a", [1.0, 2.0, 3.0, None])

s.is_null()
shape: (4,)
Series: 'is_null' [bool]
[
        false
        false
        false
        true
]
jvz
  • 1,183
  • 6
  • 13