[Numpy-discussion] index of a value in an array

Thomas, Brian (GE Energy) brian1.thomas@ge....
Wed Oct 6 08:53:58 CDT 2010


Chris,

You can use where() command to find index of a particular number in the
array.

For e.g. to find index of number 1 in array a, you can say 
idx = where(a==1)

Regards,
Brian

-----Original Message-----
From: numpy-discussion-bounces@scipy.org
[mailto:numpy-discussion-bounces@scipy.org] On Behalf Of Chris Withers
Sent: Wednesday, October 06, 2010 5:27 AM
To: numpy-discussion@scipy.org
Cc: snezana.pejic@glcuk.com
Subject: [Numpy-discussion] index of a value in an array

Hi All,

Given an array such as:

array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

How can I find the index of a particular number in the array?

(ie: if it was a list, I'd do [1,2,3,4].index(3))

cheers,

Chris
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion


More information about the NumPy-Discussion mailing list