[Numpy-discussion] Getting index of array after applying cond

Shailendra shailendra.vikas at gmail.com
Fri Apr 2 11:31:45 EDT 2010


Hi All,
I have a following model problem. Let i have a array
>>> x
array([[1, 2, 3, 4, 5],
       [6, 7, 8, 7, 6],
       [1, 2, 3, 4, 5]])

suppose i apply some cond on it.
>>> cond= x>5
>>> x[cond]
array([6, 7, 8, 7, 6])

Now, i want to argmax on this
>>> max=argmax(x[cond])
>>> max
2
>>> x[cond][max]
8
Now , I want to get the index of this element in x. How to acheive
this. In real situation x will be huge.

Thanks,
Shailendra



More information about the NumPy-Discussion mailing list