Skip to content

Commit

Permalink
Drop unsupported method argument from nunique and distinct_count.
Browse files Browse the repository at this point in the history
  • Loading branch information
bdice committed Mar 11, 2022
1 parent b613394 commit ad90493
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 13 deletions.
5 changes: 1 addition & 4 deletions python/cudf/cudf/core/column/column.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,10 +846,7 @@ def sort_by_values(
col_keys = self.take(col_inds)
return col_keys, col_inds

def distinct_count(self, method: str = "sort", dropna: bool = True) -> int:
if method != "sort":
msg = "non sort based distinct_count() not implemented yet"
raise NotImplementedError(msg)
def distinct_count(self, dropna: bool = True) -> int:
try:
return self._distinct_count[dropna]
except KeyError:
Expand Down
2 changes: 1 addition & 1 deletion python/cudf/cudf/core/dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -6020,7 +6020,7 @@ def nunique(self, axis=0, dropna=True):
if axis != 0:
raise NotImplementedError("axis parameter is not supported yet.")

return cudf.Series(super().nunique(method="sort", dropna=dropna))
return cudf.Series(super().nunique(dropna=dropna))

def _sample_axis_1(
self,
Expand Down
6 changes: 2 additions & 4 deletions python/cudf/cudf/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -6327,15 +6327,13 @@ def ge(self, other, axis="columns", level=None, fill_value=None):
other=other, op="__ge__", fill_value=fill_value, can_reindex=True
)

def nunique(self, method: str = "sort", dropna: bool = True):
def nunique(self, dropna: bool = True):
"""
Returns a per column mapping with counts of unique values for
each column.
Parameters
----------
method : str, default "sort"
Method used by cpp_distinct_count
dropna : bool, default True
Don't include NaN in the counts.
Expand All @@ -6345,7 +6343,7 @@ def nunique(self, method: str = "sort", dropna: bool = True):
Name and unique value counts of each column in frame.
"""
return {
name: col.distinct_count(method=method, dropna=dropna)
name: col.distinct_count(dropna=dropna)
for name, col in self._data.items()
}

Expand Down
6 changes: 2 additions & 4 deletions python/cudf/cudf/core/single_column_frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,12 @@ def _make_operands_for_binop(
return {result_name: (self._column, other, reflect, fill_value)}

@_cudf_nvtx_annotate
def nunique(self, method: str = "sort", dropna: bool = True):
def nunique(self, dropna: bool = True):
"""
Return count of unique values for the column.
Parameters
----------
method : str, default "sort"
Method used by cpp_distinct_count
dropna : bool, default True
Don't include NaN in the counts.
Expand All @@ -378,4 +376,4 @@ def nunique(self, method: str = "sort", dropna: bool = True):
"""
if self._column.null_count == len(self):
return 0
return self._column.distinct_count(method=method, dropna=dropna)
return self._column.distinct_count(dropna=dropna)

0 comments on commit ad90493

Please sign in to comment.