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 dask Expr.null_count #792

Merged
merged 1 commit into from
Aug 15, 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
7 changes: 7 additions & 0 deletions narwhals/_dask/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,13 @@ def func(_input: Any) -> Any:
returns_scalar=False,
)

def null_count(self: Self) -> Self:
return self._from_call(
lambda _input: _input.isna().sum(),
"null_count",
returns_scalar=True,
)

def tail(self: Self) -> NoReturn:
# We can't (yet?) allow methods which modify the index
msg = "`Expr.tail` is not supported for the Dask backend. Please use `LazyFrame.tail` instead."
Expand Down
6 changes: 1 addition & 5 deletions tests/expr_and_series/null_count_test.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from typing import Any

import pytest

import narwhals.stable.v1 as nw
from tests.utils import compare_dicts

Expand All @@ -11,9 +9,7 @@
}


def test_null_count_expr(constructor: Any, request: Any) -> None:
if "dask" in str(constructor):
request.applymarker(pytest.mark.xfail)
def test_null_count_expr(constructor: Any) -> None:
df = nw.from_native(constructor(data))
result = df.select(nw.all().null_count())
expected = {
Expand Down
Loading