diff --git a/py-polars/polars/dataframe/frame.py b/py-polars/polars/dataframe/frame.py index 837bd47b0d95..0d1d71d7c7d0 100644 --- a/py-polars/polars/dataframe/frame.py +++ b/py-polars/polars/dataframe/frame.py @@ -6992,7 +6992,7 @@ def get_column(self, name: str) -> Series: def fill_null( self, - value: Any | None = None, + value: Any | Expr | None = None, strategy: FillNullStrategy | None = None, limit: int | None = None, *, @@ -7103,7 +7103,7 @@ def fill_nan(self, value: Expr | int | float | None) -> DataFrame: Warnings -------- - Note that floating point NaNs (Not a Number) are not missing values! + Note that floating point NaNs (Not a Number) are not missing values. To replace missing values, use :func:`fill_null`. See Also diff --git a/py-polars/polars/expr/expr.py b/py-polars/polars/expr/expr.py index cd3cc21c8f77..b393b220debf 100644 --- a/py-polars/polars/expr/expr.py +++ b/py-polars/polars/expr/expr.py @@ -2832,6 +2832,11 @@ def shift( This method is similar to the `LAG` operation in SQL when the value for `n` is positive. With a negative value for `n`, it is similar to `LEAD`. + See Also + -------- + backward_fill + forward_fill + Examples -------- By default, values are shifted forward by one index. @@ -2887,7 +2892,7 @@ def shift( def fill_null( self, - value: Any | None = None, + value: Any | Expr | None = None, strategy: FillNullStrategy | None = None, limit: int | None = None, ) -> Self: @@ -2907,6 +2912,10 @@ def fill_null( Number of consecutive null values to fill when using the 'forward' or 'backward' strategy. + See Also + -------- + fill_nan + Examples -------- >>> df = pl.DataFrame( @@ -2993,6 +3002,20 @@ def fill_nan(self, value: int | float | Expr | None) -> Self: """ Fill floating point NaN value with a fill value. + Parameters + ---------- + value + Value used to fill NaN values. + + Warnings + -------- + Note that floating point NaNs (Not a Number) are not missing values. + To replace missing values, use :func:`fill_null`. + + See Also + -------- + fill_null + Examples -------- >>> df = pl.DataFrame( @@ -3025,6 +3048,11 @@ def forward_fill(self, limit: int | None = None) -> Self: limit The number of consecutive null values to forward fill. + See Also + -------- + backward_fill + shift + Examples -------- >>> df = pl.DataFrame( @@ -3056,6 +3084,11 @@ def backward_fill(self, limit: int | None = None) -> Self: limit The number of consecutive null values to backward fill. + See Also + -------- + forward_fill + shift + Examples -------- >>> df = pl.DataFrame( diff --git a/py-polars/polars/lazyframe/frame.py b/py-polars/polars/lazyframe/frame.py index d0ee96efdc65..4e4effa58bff 100644 --- a/py-polars/polars/lazyframe/frame.py +++ b/py-polars/polars/lazyframe/frame.py @@ -4909,7 +4909,7 @@ def gather_every(self, n: int, offset: int = 0) -> Self: def fill_null( self, - value: Any | None = None, + value: Any | Expr | None = None, strategy: FillNullStrategy | None = None, limit: int | None = None, *, @@ -4930,6 +4930,10 @@ def fill_null( matches_supertype Fill all matching supertypes of the fill `value` literal. + See Also + -------- + fill_nan + Examples -------- >>> lf = pl.LazyFrame( @@ -5046,8 +5050,12 @@ def fill_nan(self, value: int | float | Expr | None) -> Self: Warnings -------- - Note that floating point NaN (Not a Number) are not missing values! - To replace missing values, use :func:`fill_null` instead. + Note that floating point NaNs (Not a Number) are not missing values. + To replace missing values, use :func:`fill_null`. + + See Also + -------- + fill_null Examples -------- diff --git a/py-polars/polars/series/series.py b/py-polars/polars/series/series.py index 1d8892e08ee2..df9b9c4f63c9 100644 --- a/py-polars/polars/series/series.py +++ b/py-polars/polars/series/series.py @@ -4843,6 +4843,15 @@ def fill_nan(self, value: int | float | Expr | None) -> Series: value Value used to fill NaN values. + Warnings + -------- + Note that floating point NaNs (Not a Number) are not missing values. + To replace missing values, use :func:`fill_null`. + + See Also + -------- + fill_null + Examples -------- >>> s = pl.Series("a", [1, 2, 3, float("nan")]) @@ -4859,7 +4868,7 @@ def fill_nan(self, value: int | float | Expr | None) -> Series: def fill_null( self, - value: Any | None = None, + value: Any | Expr | None = None, strategy: FillNullStrategy | None = None, limit: int | None = None, ) -> Series: @@ -4876,6 +4885,10 @@ def fill_null( Number of consecutive null values to fill when using the 'forward' or 'backward' strategy. + See Also + -------- + fill_nan + Examples -------- >>> s = pl.Series("a", [1, 2, 3, None])