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

[REVIEW] Avoid nan_as_null op if nan_count is 0 #10082

Merged
merged 1 commit into from
Jan 25, 2022
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: 1 addition & 5 deletions python/cudf/cudf/core/column/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -1213,11 +1213,7 @@ def corr(self, other: ColumnBase):
)

def nans_to_nulls(self: T) -> T:
# Only floats can contain nan.
if self.dtype.kind != "f":
return self
newmask = libcudf.transform.nans_to_nulls(self)
return self.set_mask(newmask)
return self

def _process_for_reduction(
self, skipna: bool = None, min_count: int = 0
Expand Down
7 changes: 7 additions & 0 deletions python/cudf/cudf/core/column/numerical.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,13 @@ def binary_operator(
lhs, rhs = (self, rhs) if not reflect else (rhs, self)
return libcudf.binaryop.binaryop(lhs, rhs, binop, out_dtype)

def nans_to_nulls(self: NumericalColumn) -> NumericalColumn:
# Only floats can contain nan.
if self.dtype.kind != "f" or self.nan_count == 0:
return self
newmask = libcudf.transform.nans_to_nulls(self)
return self.set_mask(newmask)

def normalize_binop_value(
self, other: ScalarLike
) -> Union[ColumnBase, ScalarLike]:
Expand Down