Skip to content

Commit

Permalink
Raise NotImplementedError for MultiIndex.to_series (#14049)
Browse files Browse the repository at this point in the history
Fixes #14035 

This PR raises an error for `MultiIndex.to_series` because we cannot store `tuple` type columns in `cudf`.

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

Approvers:
  - Lawrence Mitchell (https://github.com/wence-)

URL: #14049
  • Loading branch information
galipremsagar authored Sep 7, 2023
1 parent dd6553a commit 7331922
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/cudf/cudf/core/multiindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,12 @@ def names(self, value):
)
self._names = pd.core.indexes.frozen.FrozenList(value)

@_cudf_nvtx_annotate
def to_series(self, index=None, name=None):
raise NotImplementedError(
"MultiIndex.to_series isn't implemented yet."
)

@_cudf_nvtx_annotate
def astype(self, dtype, copy: bool = True):
if not is_object_dtype(dtype):
Expand Down
6 changes: 6 additions & 0 deletions python/cudf/cudf/tests/test_multiindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1920,3 +1920,9 @@ def test_multiindex_sort_index_partial(levels):
expect = df.sort_index(level=levels, sort_remaining=True)
got = cdf.sort_index(level=levels, sort_remaining=True)
assert_eq(expect, got)


def test_multiindex_to_series_error():
midx = cudf.MultiIndex.from_tuples([("a", "b")])
with pytest.raises(NotImplementedError):
midx.to_series()

0 comments on commit 7331922

Please sign in to comment.