Skip to content

Commit

Permalink
Raise NotImplementedError for axis=1 in rank (#8347)
Browse files Browse the repository at this point in the history
Fixes: #8212 

This PR raises an informative error when axis is not `0`/`index`.

Authors:
  - GALI PREM SAGAR (https://github.com/galipremsagar)

Approvers:
  - Keith Kraus (https://github.com/kkraus14)

URL: #8347
  • Loading branch information
galipremsagar authored May 26, 2021
1 parent 2a19a31 commit e598361
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions python/cudf/cudf/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
)
from cudf.core.join import merge
from cudf.utils.dtypes import (
find_common_type,
is_categorical_dtype,
is_column_like,
is_decimal_dtype,
is_numerical_dtype,
is_scalar,
min_scalar_type,
find_common_type,
)

T = TypeVar("T", bound="Frame")
Expand Down Expand Up @@ -1470,7 +1470,7 @@ def rank(
Parameters
----------
axis : {0 or 'index', 1 or 'columns'}, default 0
axis : {0 or 'index'}, default 0
Index to direct ranking.
method : {'average', 'min', 'max', 'first', 'dense'}, default 'average'
How to rank the group of records that have the same value
Expand Down Expand Up @@ -1500,12 +1500,19 @@ def rank(
"""
if method not in {"average", "min", "max", "first", "dense"}:
raise KeyError(method)

method_enum = libcudf.sort.RankMethod[method.upper()]
if na_option not in {"keep", "top", "bottom"}:
raise ValueError(
"na_option must be one of 'keep', 'top', or 'bottom'"
)

if axis not in (0, "index"):
raise NotImplementedError(
f"axis must be `0`/`index`, "
f"axis={axis} is not yet supported in rank"
)

source = self
if numeric_only:
numeric_cols = (
Expand Down

0 comments on commit e598361

Please sign in to comment.