From 04ee729f583ffd44f73483f25a080d880c959f41 Mon Sep 17 00:00:00 2001 From: GALI PREM SAGAR Date: Wed, 30 Aug 2023 16:05:35 -0500 Subject: [PATCH] Fix return type of `MultiIndex.difference` (#14009) closes #14008 This PR ensures `MultiIndex.difference` returns `cudf.MultiIndex`. Authors: - GALI PREM SAGAR (https://github.com/galipremsagar) Approvers: - Matthew Roeschke (https://github.com/mroeschke) - Bradley Dice (https://github.com/bdice) URL: https://github.com/rapidsai/cudf/pull/14009 --- python/cudf/cudf/core/multiindex.py | 2 +- python/cudf/cudf/tests/test_multiindex.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/python/cudf/cudf/core/multiindex.py b/python/cudf/cudf/core/multiindex.py index eb953a54f6b..12da69740d8 100644 --- a/python/cudf/cudf/core/multiindex.py +++ b/python/cudf/cudf/core/multiindex.py @@ -1637,7 +1637,7 @@ def memory_usage(self, deep=False): def difference(self, other, sort=None): if hasattr(other, "to_pandas"): other = other.to_pandas() - return self.to_pandas().difference(other, sort) + return cudf.from_pandas(self.to_pandas().difference(other, sort)) @_cudf_nvtx_annotate def append(self, other): diff --git a/python/cudf/cudf/tests/test_multiindex.py b/python/cudf/cudf/tests/test_multiindex.py index bc9cf20b711..eedc9b0c174 100644 --- a/python/cudf/cudf/tests/test_multiindex.py +++ b/python/cudf/cudf/tests/test_multiindex.py @@ -1697,6 +1697,7 @@ def test_difference(): expected = midx2.to_pandas().difference(midx.to_pandas()) actual = midx2.difference(midx) + assert isinstance(actual, cudf.MultiIndex) assert_eq(expected, actual)