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.max and test #691

Merged
merged 1 commit into from
Jul 31, 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
6 changes: 6 additions & 0 deletions narwhals/_dask/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ def min(self) -> Self:
"min",
)

def max(self) -> Self:
return self._from_call(
lambda _input: _input.max(),
"max",
)

def shift(self, n: int) -> Self:
return self._from_call(
lambda _input, n: _input.shift(n),
Expand Down
10 changes: 10 additions & 0 deletions tests/dask_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ def test_min() -> None:
compare_dicts(result, expected)


def test_max() -> None:
import dask.dataframe as dd

dfdd = dd.from_pandas(pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}))
df = nw.from_native(dfdd)
result = df.with_columns((nw.col("a") + nw.col("b").max()).alias("c"))
expected = {"a": [1, 2, 3], "b": [4, 5, 6], "c": [7, 8, 9]}
compare_dicts(result, expected)


def test_cum_sum() -> None:
import dask.dataframe as dd

Expand Down
Loading