From 3c9d7e769d3d952401873eb10828dc0fb205205a Mon Sep 17 00:00:00 2001 From: martinfalisse Date: Thu, 3 Feb 2022 09:30:28 +0100 Subject: [PATCH] Remove unnecessary nunique function in Series. --- python/cudf/cudf/core/series.py | 36 -------------------- python/cudf/cudf/core/single_column_frame.py | 2 ++ 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/python/cudf/cudf/core/series.py b/python/cudf/cudf/core/series.py index 12a2538b776..24237c46c2f 100644 --- a/python/cudf/cudf/core/series.py +++ b/python/cudf/cudf/core/series.py @@ -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, diff --git a/python/cudf/cudf/core/single_column_frame.py b/python/cudf/cudf/core/single_column_frame.py index ef479f19363..599224a6995 100644 --- a/python/cudf/cudf/core/single_column_frame.py +++ b/python/cudf/cudf/core/single_column_frame.py @@ -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)