I am evaluating a float variable in Pandas, and I want the ranks to be unique (without duplicate ranks in case of links).
Here's what happens:
vals = pd.Series([0.0133, 0.0018, np.nan, 0.0006, 0.0006]) vals.rank(ascending=False, method='dense') 0 1.0 1 2.0 2 NaN 3 3.0 4 3.0
I would like the result to be
0 1.0 1 2.0 2 NaN 3 3.0 4 4.0
Can I do this using the rank method, or do I need to do this manually using some sorting and looping logic?
Chris source share