0

Is there a function that can be applied to a pandas column that is equivalent to the index function of python list? I.e. search a column for a particular value, then break when it encounters first instance of that value and return the index.

eg.

l = ['a','b','b']
l.index('b')

returns 1.

The closest I can find in Pandas , if the same data was in a column:

(l == 'b').nonzero()[0][0]

Which seems a bit wasteful in instances where I have a big column with lots of repeat values

John Greenall
  • 1,670
  • 11
  • 17
  • Looks like it's been asked and discussed [here](http://stackoverflow.com/questions/18327624/find-elements-index-in-pandas-series) – Jon Clements Feb 27 '15 at 11:15
  • @JonClements agreed. I have marked as duplicate. Shame there is no satisfactory answer there... – John Greenall Feb 27 '15 at 11:48
  • okay... wasn't sure to vote to close, but if you're happy that's a dupe that's fine... (might be worth as it's come up a couple of times making an issue on the project tracker/see if there's already an issue but no resolution and give it a chase or something...) – Jon Clements Feb 27 '15 at 11:49

0 Answers0