user6162407
user6162407

Reputation: 267

Getting ordered value

I have the following Series:

ser = pd.Series({'a': 10, 'b': 21, 'c': 12, 'd': 5, 'e': 26, 'd': 17})

Which method can I use to identify the order of an element relative to others? For example, if I sort the Series in ascending order c is in the second position.

Upvotes: 1

Views: 48

Answers (1)

user2285236
user2285236

Reputation:

You can use the rank method:

ser.rank()
Out[178]: 
a    1.0
b    4.0
c    2.0
d    3.0
e    5.0
dtype: float64

Upvotes: 3

Related Questions