BUG: rank does not respect na_option='keep'
for numpy nullable integer dtypes
#56976
Closed
3 tasks done
Labels
Bug
NA - MaskedArrays
Related to pd.NA and nullable extension arrays
Transformations
e.g. cumsum, diff, rank
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
pd.Series.rank
does not keep missing values for certain dtypes, even whenna_option='keep'
is set (the default).Instead they receive rank values ordered somewhere inbetween.
I experienced this behaviour in numpy-nullable integer dtypes.
It does not seem to appear for
object
, numpy-nullable floats or pyarrow floats/ints.Expected Behavior
Expected output would be the one of plain
s.rank()
However, running the code yields
2.5
instead of theNaN
and the other numbers are shifted as well.Installed Versions
The text was updated successfully, but these errors were encountered: