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

[BUG] DataFrame.rank() ignores axis option #8212

Closed
tfeher opened this issue May 11, 2021 · 2 comments · Fixed by #8347
Closed

[BUG] DataFrame.rank() ignores axis option #8212

tfeher opened this issue May 11, 2021 · 2 comments · Fixed by #8347
Assignees
Labels
bug Something isn't working Python Affects Python cuDF API.

Comments

@tfeher
Copy link

tfeher commented May 11, 2021

Describe the bug
The DataFrame.rank() method ignores the axis option and ranks always along axis=0.

Steps/Code to reproduce bug

import cudf
import numpy as np
gdf = cudf.DataFrame(data={'A': [4, 2, 4, 8, np.nan], 'B':[5,4,3,2,1]})
gdf.rank(axis=1)

This gives

  A B
2.5 5.0
1.0 4.0
2.5 3.0
4.0 2.0
NA 1.0

Expected behavior

Rank along columns when axis=1 is specified. Here is the expected output produced by pandas

import pandas as pd
df = pd.DataFrame(data={'A': [4, 2, 4, 8, np.nan], 'B':[5,4,3,2,1]})
df.rank(axis=1)

Prints:

A B
1.0 2.0
1.0 2.0
2.0 1.0
2.0 1.0
NaN 1.0

Environment overview

Tested with 0.20 nightly docker image (rapidsai/rapidsai-core-dev-nightly:0.20-cuda11.2-devel-ubuntu18.04-py3.8).

Additional context
The ranking method is used by cheminformatics

@tfeher tfeher added Needs Triage Need team to review and classify bug Something isn't working labels May 11, 2021
@mlgill
Copy link

mlgill commented May 12, 2021

Thanks for filing this @tfeher -- this exactly the describes the bug as I initially identified it.

@kkraus14 kkraus14 added Python Affects Python cuDF API. and removed Needs Triage Need team to review and classify labels May 14, 2021
@kkraus14
Copy link
Collaborator

We should at least be throwing for now that we don't yet support axis=1.

@galipremsagar galipremsagar self-assigned this May 25, 2021
rapids-bot bot pushed a commit that referenced this issue May 26, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants