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

Robert Robert robertrobert93@yahoo....
Mon Jul 13 03:03:05 CDT 2009


Hi,
I've seen this function where, but it requires three inputs and I have no clue how to use it. Is it possible to give me an example. E.g I have an array as

a = [ [1,2,3], 
        [4,5,6],
        [7,8,9] ]

and I would like to retrieve the indexes of values 9 which are 2, 2.
How do I do that with scipy.where ?
Thanks,
robert

--- On Mon, 7/13/09, David Warde-Farley <dwf@cs.toronto.edu> wrote:

From: David Warde-Farley <dwf@cs.toronto.edu>
Subject: Re: [SciPy-user] retrieve indexes of 2D array element
To: "SciPy Users List" <scipy-user@scipy.org>
Date: Monday, July 13, 2009, 7:11 AM

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
_______________________________________________
SciPy-user mailing list
SciPy-user@scipy.org
http://mail.scipy.org/mailman/listinfo/scipy-user



      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20090713/5953bd7c/attachment.html 


More information about the SciPy-user mailing list