diff --git a/python/cudf/cudf/core/column/numerical.py b/python/cudf/cudf/core/column/numerical.py index 97d193d51ba..d78d15fb9c5 100644 --- a/python/cudf/cudf/core/column/numerical.py +++ b/python/cudf/cudf/core/column/numerical.py @@ -225,7 +225,10 @@ def _binaryop(self, other: ColumnBinaryOperand, op: str) -> ColumnBase: (tmp.dtype.type in int_float_dtype_mapping) and (tmp.dtype.type != np.bool_) and ( - (np.isscalar(tmp) and (0 == tmp)) + ( + (np.isscalar(tmp) or isinstance(tmp, cudf.Scalar)) + and (0 == tmp) + ) or ( (isinstance(tmp, NumericalColumn)) and (0.0 in tmp) ) diff --git a/python/cudf/cudf/tests/test_binops.py b/python/cudf/cudf/tests/test_binops.py index 2229bcc1938..e8434509992 100644 --- a/python/cudf/cudf/tests/test_binops.py +++ b/python/cudf/cudf/tests/test_binops.py @@ -877,6 +877,21 @@ def test_binop_bool_uint(func, rhs): ) +@pytest.mark.parametrize( + "series_dtype", (np.bool_, np.int8, np.uint8, np.int64, np.uint64) +) +@pytest.mark.parametrize( + "scalar_dtype", (np.bool_, np.int8, np.uint8, np.int64, np.uint64) +) +def test_floordiv_zero_float64(series_dtype, scalar_dtype): + sr = pd.Series([1, 2, 3], dtype=series_dtype) + cr = cudf.from_pandas(sr) + + utils.assert_eq( + (sr // scalar_dtype(0)), (cr // cudf.Scalar(0, dtype=scalar_dtype)) + ) + + def test_series_misc_binop(): pds = pd.Series([1, 2, 4], name="abc xyz") gds = cudf.Series([1, 2, 4], name="abc xyz")