Dec. 10, 2008
4:43 p.m.
Ross Williamson wrote:
Hi Everyone
I think I'm missing something really obvious but what I would like to do is extract the indexes from an array where a number matches - For example
data = [0,1,2,960,5,6,960,7]
I would like to know, for example the indices which match 960 - i.e. it would return 3 and 6
import numpy as np In[14]: np.where( np.array( data ) == 960 ) Out[14]: (array([3, 6]),) If you need to count all of the items, try something like np.histogram( data, np.max( data ) ) cheers, r.