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

Add isna #76

Merged
merged 1 commit into from
May 10, 2023
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
8 changes: 8 additions & 0 deletions dask_expr/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,9 @@ def count(self, numeric_only=None):
def astype(self, dtypes):
return AsType(self, dtypes)

def isna(self):
return IsNa(self)

def apply(self, function, *args, **kwargs):
return Apply(self, function, args, kwargs)

Expand Down Expand Up @@ -721,6 +724,11 @@ class AsType(Elemwise):
operation = M.astype


class IsNa(Elemwise):
_parameters = ["frame"]
operation = M.isna


class Apply(Elemwise):
"""A good example of writing a less-trivial blockwise operation"""

Expand Down
2 changes: 2 additions & 0 deletions dask_expr/tests/test_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ def test_conditionals(func, pdf, df):
lambda df: df.apply(lambda row, x, y=10: row * x + y, x=2),
lambda df: df[df.x > 5],
lambda df: df.assign(a=df.x + df.y, b=df.x - df.y),
lambda df: df.isna(),
lambda df: df.x.isna(),
Comment on lines +126 to +127
Copy link
Member

Choose a reason for hiding this comment

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

We may want pdf to have at least one null for features like this. Or perhaps we have a pdf_nulls fixture?

],
)
def test_blockwise(func, pdf, df):
Expand Down