Skip to content

ENH: Allow rank to return int64 for numpy types when no missing values are present #55598

Open
@mroeschke

Description

@mroeschke
In [2]: import pandas as pd

In [3]: df = pd.DataFrame({'a': [1, 1, 1, 2, 2], 'b': [1,2 ,3, 4, 5]})

In [4]: df.groupby('a').rank(method='min')
Out[4]: 
     b
0  1.0
1  2.0
2  3.0
3  1.0
4  2.0

In [5]: df.rank()
Out[5]: 
     a    b
0  2.0  1.0
1  2.0  2.0
2  2.0  3.0
3  4.5  4.0
4  4.5  5.0

In these cases, it would be more natural to return int64 instead of float64

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions