Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(python): Ensure consistent docstring warning in fill_nan methods (pointing out that nan isn't null) #16061

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions py-polars/polars/dataframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
*,
Expand Down Expand Up @@ -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
Expand Down
35 changes: 34 additions & 1 deletion py-polars/polars/expr/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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:
Expand All @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down
14 changes: 11 additions & 3 deletions py-polars/polars/lazyframe/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
*,
Expand All @@ -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(
Expand Down Expand Up @@ -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
--------
Expand Down
15 changes: 14 additions & 1 deletion py-polars/polars/series/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")])
Expand All @@ -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:
Expand All @@ -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])
Expand Down
Loading