Skip to content

Commit

Permalink
add dask null-count
Browse files Browse the repository at this point in the history
  • Loading branch information
anopsy committed Aug 14, 2024
1 parent 54ba924 commit d7323f8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
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

0 comments on commit d7323f8

Please sign in to comment.