polars.Series.fill_null
-
Fill null values using the specified value or strategy.
- Parameters:
-
- value
-
Value used to fill null values.
-
strategy{None, ‘forward’, ‘backward’, ‘min’, ‘max’, ‘mean’, ‘zero’, ‘one’} -
Strategy used to fill null values.
- limit
-
Number of consecutive null values to fill when using the ‘forward’ or ‘backward’ strategy.
See also
Notes
A null value is not the same as a NaN value. To fill NaN values, use
fill_nan().Examples
>>> s = pl.Series("a", [1, 2, 3, None]) >>> s.fill_null(strategy="forward") shape: (4,) Series: 'a' [i64] [ 1 2 3 3 ] >>> s.fill_null(strategy="min") shape: (4,) Series: 'a' [i64] [ 1 2 3 1 ] >>> s = pl.Series("b", ["x", None, "z"]) >>> s.fill_null(pl.lit("")) shape: (3,) Series: 'b' [str] [ "x" "" "z" ]
Series.fill_null(
value: Any | Expr | None = None,
strategy: FillNullStrategy | None = None,
limit: int | None = None,
) → Series
© 2020 Ritchie Vink
© 2022 Polars contributors
Licensed under the MIT License.
https://docs.pola.rs/api/python/stable/reference/series/api/polars.Series.fill_null.html