Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary nunique function in Series. #10205

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions python/cudf/cudf/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2722,42 +2722,6 @@ def unique(self):
res = self._column.unique()
return Series(res, name=self.name)

def nunique(self, method="sort", dropna=True):
"""Returns the number of unique values of the Series: approximate version,
and exact version to be moved to libcudf
Excludes NA values by default.
Parameters
----------
dropna : bool, default True
Don't include NA values in the count.
Returns
-------
int
Examples
--------
>>> import cudf
>>> s = cudf.Series([1, 3, 5, 7, 7])
>>> s
0 1
1 3
2 5
3 7
4 7
dtype: int64
>>> s.nunique()
4
"""
if method != "sort":
msg = "non sort based distinct_count() not implemented yet"
raise NotImplementedError(msg)
if self.null_count == len(self):
return 0
return super().nunique(method, dropna)

def value_counts(
self,
normalize=False,
Expand Down
2 changes: 2 additions & 0 deletions python/cudf/cudf/core/single_column_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,4 +343,6 @@ def nunique(self, method: builtins.str = "sort", dropna: bool = True):
int
Number of unique values in the column.
"""
if self._column.null_count == len(self):
return 0
return self._column.distinct_count(method=method, dropna=dropna)