Skip to content

BUG: rank with object dtype and small values #62036

@jbrockmendel

Description

@jbrockmendel
# Based on test_rank_ea_small_values
import pandas as pd

ser = pd.Series(
    [5.4954145e29, -9.791984e-21, 9.3715776e-26, pd.NA, 1.8790257e-28],
    dtype="Float64",
)
ser2 = ser.astype(object)

>>> ser.rank(method="min")
0    4.0
1    1.0
2    3.0
3    NaN
4    2.0
dtype: float64

>>> ser2.rank(method="min")
0    4.0
1    1.0
2    1.0
3    NaN
4    1.0
dtype: float64

I'd expect 1) the values to match and 2) to get NA rather than NaN at least for the Float64 case.

Update: if we convert to float64[pyarrow] first we do get NA back and a uint64[pyarrow] dtype.

Metadata

Metadata

Assignees

Labels

BugMissing-datanp.nan, pd.NaT, pd.NA, dropna, isnull, interpolateNA - MaskedArraysRelated to pd.NA and nullable extension arraysTransformationse.g. cumsum, diff, rank

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions