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_in to DaskExpr and mark is_duplicated and is_unique as not implemented #802

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

def is_duplicated(self: Self) -> Self:
msg = "`Expr.is_duplicated` is not support since Dask currently has no native duplicated check"
raise NotImplementedError(msg)

def is_unique(self: Self) -> Self:
msg = "`Expr.is_duplicated` is not support since Dask currently has no native duplicated check"
Copy link
Member

@FBruzzesi FBruzzesi Aug 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am late but

-        msg = "`Expr.is_duplicated` is not support since Dask currently has no native duplicated check"
+        msg = "`Expr.is_unique` is not support since Dask currently has no native duplicated check" 

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aah crap, thanks - fancy bundling this in with another one?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doh! Sorry both πŸ€¦β€β™‚οΈ

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No worries! I tend to say that until a release we are fine to mess up a bit πŸ˜‚

raise NotImplementedError(msg)

def is_in(self: Self, other: Any) -> Self:
return self._from_call(
lambda _input, other: _input.isin(other),
"is_in",
other,
returns_scalar=False,
)

def null_count(self: Self) -> Self:
return self._from_call(
lambda _input: _input.isna().sum(),
Expand Down
4 changes: 1 addition & 3 deletions tests/expr_and_series/is_in_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@
data = {"a": [1, 4, 2, 5]}


def test_expr_is_in(constructor: Any, request: Any) -> None:
if "dask" in str(constructor):
request.applymarker(pytest.mark.xfail)
def test_expr_is_in(constructor: Any) -> None:
df = nw.from_native(constructor(data))
result = df.select(nw.col("a").is_in([4, 5]))
expected = {"a": [False, True, False, True]}
Expand Down
Loading