camphor
camphor

Reputation: 71

Replace each value in Series with its relative ranking

I have a sorted Series, is there a simple way to change it from

A    0.064467
B    0.042283
C    0.037581
D    0.017410
dtype: float64

to

A    1
B    2
C    3
D    4

Upvotes: 2

Views: 32

Answers (1)

BENY
BENY

Reputation: 323266

You can just do rank

df.rank(ascending=False)

Upvotes: 1

Related Questions