[Numpy-discussion] Getting indices from numpy array with condition

David Warde-Farley dwf at cs.toronto.edu
Tue Nov 18 05:48:06 EST 2008


On 18-Nov-08, at 5:29 AM, Nicolas ROUX wrote:

> Hi,
>
> Maybe this is not so clever, but I can't find it in the doc.
> I need to get all indices/index of all occurrences of a value in a  
> numpy
> array
>
>
> As example:
>
> a = numpy.array([1,2,3],[4,5,6],[7,8,9])
> I need to get the indice/index of all array elements where a[a>3]

numpy.where(a > 3)

David



More information about the NumPy-Discussion mailing list