Skip to content
Merged
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
17 changes: 10 additions & 7 deletions python/cudf/cudf/tests/dataframe/methods/test_apply.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: Copyright (c) 2021-2025, NVIDIA CORPORATION.
# SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION.
# SPDX-License-Identifier: Apache-2.0
import decimal
import math
Expand Down Expand Up @@ -66,7 +66,9 @@ def run_masked_udf_test(func, data, args=(), nullable=True, **kwargs):
pdf = data.to_pandas(nullable=nullable)

expect = pdf.apply(func, args=args, axis=1)
obtain = gdf.apply(func, args=args, axis=1)
obtain = gdf.apply(func, args=args, axis=1).to_pandas(nullable=nullable)
if "check_dtype" in kwargs and not kwargs.get("check_dtype", True):
expect = expect.astype(obtain.dtype)
assert_eq(expect, obtain, **kwargs)


Expand Down Expand Up @@ -530,7 +532,6 @@ def func(row):
gdf = cudf.DataFrame({"a": [1.5, None, 3, None], "b": [4, 5, None, None]})
gdf["a"] = gdf["a"].astype(numeric_types_as_str)
gdf["b"] = gdf["b"].astype(numeric_types_as_str2)

run_masked_udf_test(func, gdf, check_dtype=False)


Expand Down Expand Up @@ -673,8 +674,8 @@ def outer_gpu(row):
y = row["b"]
return inner_gpu(x, y)

got = gdf.apply(outer_gpu, axis=1)
expect = pdf.apply(outer, axis=1)
got = gdf.apply(outer_gpu, axis=1).to_pandas(nullable=True)
expect = pdf.apply(outer, axis=1).astype(got.dtype)
assert_eq(expect, got, check_dtype=False)


Expand All @@ -691,7 +692,7 @@ def func(row):
return row["a"] + row["b"]

data = cudf.DataFrame(data)
run_masked_udf_test(func, data)
run_masked_udf_test(func, data, check_dtype=False)


@pytest.mark.parametrize(
Expand Down Expand Up @@ -770,4 +771,6 @@ def func(row, c, k):
y = binary_op(x, k)
return y

run_masked_udf_test(func, data, args=(1, 2), check_dtype=False)
run_masked_udf_test(
func, data, args=(1, 2), check_dtype=False, nullable=True
)
Loading