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

Drop unsupported method argument from nunique and distinct_count. #10411

Merged
merged 1 commit into from
Mar 11, 2022
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
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)