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.count #731

Merged
merged 4 commits into from
Aug 8, 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 @@ -405,6 +405,13 @@ def sum(self) -> Self:
returns_scalar=True,
)

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

def round(self, decimals: int) -> Self:
return self._from_call(
lambda _input, decimals: _input.round(decimals),
Expand Down
6 changes: 1 addition & 5 deletions tests/expr_and_series/count_test.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
from typing import Any

import pytest

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


def test_count(constructor: Any, request: Any) -> None:
if "dask" in str(constructor):
request.applymarker(pytest.mark.xfail)
def test_count(constructor: Any) -> None:
data = {"a": [1, 3, 2], "b": [4, None, 6], "z": [7.0, None, None]}
df = nw.from_native(constructor(data))
result = df.select(nw.col("a", "b", "z").count())
Expand Down
Loading