Skip to content

Series/DataFrame.rank() doesn't handle np.inf properly #6945

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

Closed
nspies opened this issue Apr 23, 2014 · 3 comments · Fixed by #17903
Closed

Series/DataFrame.rank() doesn't handle np.inf properly #6945

nspies opened this issue Apr 23, 2014 · 3 comments · Fixed by #17903
Labels
Bug Numeric Operations Arithmetic, Comparison, and Logical operations
Milestone

Comments

@nspies
Copy link
Contributor

nspies commented Apr 23, 2014

The rank() function converts np.nan to np.inf or -np.inf, and therefore can't properly rank existing np.inf. See here: #6886 (comment).

Test for this issue here: https://github.com/pydata/pandas/blob/master/pandas/tests/test_series.py#L4071

@jreback
Copy link
Contributor

jreback commented Apr 23, 2014

@nspies this has your name on it too!

@jreback jreback modified the milestones: 0.16.0, Next Major Release Mar 6, 2015
@peterpanmj
Copy link
Contributor

I'm using pandas '0.20.1'. Ranking series with np.inf still yields np.nan. Will this be fixed ?

s= pd.Series(data = np.array([1,2,3,math.inf,4,4,4,5,5]))
s.rank(method="average")
0    1.0
1    2.0
2    3.0
3    NaN
4    5.0
5    5.0
6    5.0
7    7.5
8    7.5
dtype: float64

@jreback
Copy link
Contributor

jreback commented Sep 22, 2017

@peterpanmj pull request for this are welcome, its pretty straightforward to fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Numeric Operations Arithmetic, Comparison, and Logical operations
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants