diff --git a/python/cudf/cudf/core/indexed_frame.py b/python/cudf/cudf/core/indexed_frame.py index 69b25c51a66..41c6e21499d 100644 --- a/python/cudf/cudf/core/indexed_frame.py +++ b/python/cudf/cudf/core/indexed_frame.py @@ -1961,6 +1961,11 @@ def drop_duplicates( ignore_index: bool, default False If True, the resulting axis will be labeled 0, 1, ..., n - 1. """ + if not isinstance(ignore_index, bool): + raise ValueError( + f"{ignore_index=} must be bool, " + f"not {type(ignore_index).__name__}" + ) subset = self._preprocess_subset(subset) subset_cols = [name for name in self._column_names if name in subset] if len(subset_cols) == 0: diff --git a/python/cudf/cudf/tests/test_duplicates.py b/python/cudf/cudf/tests/test_duplicates.py index 8a83ec150bc..f77e7b4d775 100644 --- a/python/cudf/cudf/tests/test_duplicates.py +++ b/python/cudf/cudf/tests/test_duplicates.py @@ -623,3 +623,9 @@ def test_drop_duplicates_multi_index(): gdf[col].drop_duplicates().to_pandas(), pdf[col].drop_duplicates(), ) + + +def test_drop_duplicates_ignore_index_wrong_type(): + gdf = cudf.DataFrame([1, 1, 2]) + with pytest.raises(ValueError): + gdf.drop_duplicates(ignore_index="True")