Skip to content

Commit

Permalink
Remove unnecessary nunique function in Series.
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfalisse committed Feb 3, 2022
1 parent a25a2ec commit 3c9d7e7
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 36 deletions.
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)

0 comments on commit 3c9d7e7

Please sign in to comment.