Skip to content

Commit

Permalink
Retain series name in Series.apply (#10716)
Browse files Browse the repository at this point in the history
  • Loading branch information
brandon-b-miller authored Apr 26, 2022
1 parent a1c7cbe commit 62005f2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion python/cudf/cudf/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2110,7 +2110,10 @@ def apply(self, func, convert_dtype=True, args=(), **kwargs):
"""
if convert_dtype is not True:
raise ValueError("Series.apply only supports convert_dtype=True")
return self._apply(func, _get_scalar_kernel, *args, **kwargs)

result = self._apply(func, _get_scalar_kernel, *args, **kwargs)
result.name = self.name
return result

@_cudf_nvtx_annotate
def applymap(self, udf, out_dtype=None):
Expand Down
7 changes: 5 additions & 2 deletions python/cudf/cudf/tests/test_udf_masked_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,12 @@ def func(row):


@pytest.mark.parametrize(
"data", [cudf.Series([1, 2, 3]), cudf.Series([1, cudf.NA, 3])]
"data,name",
[([1, 2, 3], None), ([1, cudf.NA, 3], None), ([1, 2, 3], "test_name")],
)
def test_series_apply_basic(data):
def test_series_apply_basic(data, name):
data = cudf.Series(data, name=name)

def func(x):
return x + 1

Expand Down

0 comments on commit 62005f2

Please sign in to comment.