[SciPy-user] retrieve indexes of 2D array element

David Warde-Farley dwf at cs.toronto.edu
Mon Jul 13 03:11:05 EDT 2009


On 13-Jul-09, at 2:56 AM, Robert Robert wrote:

> Hi all,
> I have a 2D scipy array of integer. I can not figure out how to  
> retrieve the indexes i, j of a specific element in the array. I can  
> loop through the array in python and search for it, but I can not  
> believe that scipy does not have a highly optimized algorithm.
> Thanks,
> robert


By a specific element, do you mean a certain value? If so use a  
boolean condition and where().

http://docs.scipy.org/doc/numpy/reference/generated/numpy.where.html

David



More information about the SciPy-User mailing list