I'm using numpy.argmax
to calculate the first index where True
can be found in a vector of bools. Invoking on a pandas.Series
gives me the Series index rather than the element index.
I found a subtle bug in my code that popped up when the vector was all False; returning index 0 in this case seems dangerous since True could very well be the case where True was in the first element. What's the design choice for this return value?
>>> numpy.argmax([False,False,False])
0
>>> numpy.argmax([True, False, True])
0
>>> s = pandas.Series( [ False, False, False ] , index=[3,6,9] )
>>> numpy.argmax(s)
3
>>> s1 = pandas.Series( [ True, False, False ] , index=[3,6,9] )
>>> numpy.argmax(s1)
3