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

feat: add is_nan expression & series method #1625

Merged
merged 19 commits into from
Jan 3, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
enh is_nan documentation
- link out to pandas_like_concepts/null_handling
- remove stale raises
- fix returns for Series to be more specific
camriddell committed Dec 30, 2024
commit b74e65cae28972a03bfaa190a9b430d42c5da388
10 changes: 4 additions & 6 deletions narwhals/expr.py
Original file line number Diff line number Diff line change
@@ -1926,17 +1926,15 @@ def is_null(self) -> Self:
return self.__class__(lambda plx: self._to_compliant_expr(plx).is_null())

def is_nan(self) -> Self:
"""Returns a boolean Series indicating which values are NaN.
"""Indicate which values are NaN.

Returns:
A new expression.

Raises:
narwhals.InvalidOperationError for non-Float64 dtypes.

Notes:
pandas, Polars and PyArrow handle null values differently. Polars and PyArrow
distinguish between NaN and Null, whereas pandas doesn't.
pandas handles null values differently from Polars and PyArrow.
See [null_handling](../pandas_like_concepts/null_handling.md/)
for reference.

Examples:
>>> import pandas as pd
10 changes: 4 additions & 6 deletions narwhals/series.py
Original file line number Diff line number Diff line change
@@ -2036,14 +2036,12 @@ def is_nan(self) -> Self:
"""Returns a boolean Series indicating which values are NaN.

Returns:
A new Series.

Raises:
narwhals.InvalidOperationError for non-Float64 dtypes.
A boolean Series indicating which values are NaN.

Notes:
pandas and Polars handle NaN values differently. Polars distinguishes
between NaN and Null, whereas pandas doesn't.
pandas handles null values differently from Polars and PyArrow.
See [null_handling](../pandas_like_concepts/null_handling.md/)
for reference.

Examples:
>>> import pandas as pd