diff --git a/python/cudf/cudf/core/multiindex.py b/python/cudf/cudf/core/multiindex.py index 6e9d068ef50..b2a58800e23 100644 --- a/python/cudf/cudf/core/multiindex.py +++ b/python/cudf/cudf/core/multiindex.py @@ -730,18 +730,12 @@ def isin(self, values, level=None): values_idx = cudf.MultiIndex.from_tuples( values, names=self.names ) - - res = [] - for name in self.names: - level_idx = self.get_level_values(name) - value_idx = values_idx.get_level_values(name) - - existence = level_idx.isin(value_idx) - res.append(existence) - - result = res[0] - for i in res[1:]: - result = result & i + self_df = self.to_frame(index=False).reset_index() + values_df = values_idx.to_frame(index=False) + idx = self_df.merge(values_df)._data["index"] + res = cudf.core.column.full(size=len(self), fill_value=False) + res[idx] = True + result = res.values else: level_series = self.get_level_values(level) result = level_series.isin(values) diff --git a/python/cudf/cudf/tests/test_index.py b/python/cudf/cudf/tests/test_index.py index 2da3d3d3ce1..aefaacdac29 100644 --- a/python/cudf/cudf/tests/test_index.py +++ b/python/cudf/cudf/tests/test_index.py @@ -2235,11 +2235,15 @@ def test_isin_index(data, values): [[1, 2, 3, 10, 100], ["red", "blue", "green", "pink", "white"]], names=("number", "color"), ), + pd.MultiIndex.from_product( + [[0, 1], ["red", "blue", "green"]], names=("number", "color") + ), ], ) @pytest.mark.parametrize( "values,level,err", [ + ([(1, "red"), (2, "blue"), (0, "green")], None, None), (["red", "orange", "yellow"], "color", None), (["red", "white", "yellow"], "color", None), ([0, 1, 2, 10, 11, 15], "number", None),