diff --git a/python/cudf/cudf/core/column/column.py b/python/cudf/cudf/core/column/column.py index 1a83194489d..7999fa9039b 100644 --- a/python/cudf/cudf/core/column/column.py +++ b/python/cudf/cudf/core/column/column.py @@ -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 diff --git a/python/cudf/cudf/core/column/numerical.py b/python/cudf/cudf/core/column/numerical.py index 2b0d7cfea38..a7481ce62a3 100644 --- a/python/cudf/cudf/core/column/numerical.py +++ b/python/cudf/cudf/core/column/numerical.py @@ -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]: