Skip to content

Commit

Permalink
Raise NotImplementedError for Series.rename that's not a scalar (#16525)
Browse files Browse the repository at this point in the history
xref #16507

Raising a `NotImplementedError` gives a chance for this work in `cudf.pandas`

Authors:
  - Matthew Roeschke (https://github.com/mroeschke)

Approvers:
  - GALI PREM SAGAR (https://github.com/galipremsagar)

URL: #16525
  • Loading branch information
mroeschke authored Aug 14, 2024
1 parent bf3372b commit d684ae0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions python/cudf/cudf/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -3589,6 +3589,10 @@ def rename(
raise NotImplementedError("level is currently not supported.")
if errors != "ignore":
raise NotImplementedError("errors is currently not supported.")
if not is_scalar(index):
raise NotImplementedError(
".rename does not currently support relabeling the index."
)
out_data = self._data.copy(deep=copy)
return Series._from_data(out_data, self.index, name=index)

Expand Down
7 changes: 7 additions & 0 deletions python/cudf/cudf/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2289,6 +2289,13 @@ def test_series_rename(initial_name, name):
assert_eq(actual, expected)


@pytest.mark.parametrize("index", [lambda x: x * 2, {1: 2}])
def test_rename_index_not_supported(index):
ser = cudf.Series(range(2))
with pytest.raises(NotImplementedError):
ser.rename(index=index)


@pytest.mark.parametrize(
"data",
[
Expand Down

0 comments on commit d684ae0

Please sign in to comment.