
On Wed, Oct 6, 2010 at 7:23 AM, Nicolas Bigaouette <nbigaouette@gmail.com>wrote:
On Wed, Oct 6, 2010 at 5:26 AM, Chris Withers <chris@simplistix.co.uk>wrote:
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
Try with numpy.where(array == value) and plain "array == value" IIRC, the first will return an array the size of the found elements and the second will return an array (or list?) of True/False. Either can be used as "index = numpy.where()" and "index = (array == value)" and then "array[index]". N
Wouldn't it be more technically correct to use numpy.nonzero()? Returning the index is a special behavior of not specifying the second argument to numpy.where(). Ben Root