18

How is it possible to retrieve the labe of a particular value in a pandas Series object:

For example:

labels = ['a', 'b', 'c', 'd', 'e'] s = Series (arange(5) * 4 , labels) 

Which produces the Series:

a 0 b 4 c 8 d 12 e 16 dtype: int64 

How is it possible to get the label of value '12'? Thanks

1 Answer 1

19

You can get the subseries by:

In [90]: s[s==12] Out[90]: d 12 dtype: int64 

Moreover, you can get those labels by

In [91]: s[s==12].index Out[91]: Index([d], dtype=object) 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.