Referencing cells in arrays (numpy)

Charles Boncelet boncelet at udel.edu
Wed May 10 21:33:14 EDT 2000


Duncan Smith wrote:

> I am struggling to find out how to reference individual cells in a
> multidimensional array.  I just don't seem able to find the relevant section
> of numeric.pdf.

>>>a = array([[1,2,3],[4,5,6]])
>>>a[0,0]
1
>>>a[1][2]
6
(You can use either notation.)

> Also, I only want to consider certain cells, so I'm looking for an efficient
> method of 'pruning' the array.  I'm currently using 'resize', but that still
> leaves me with a fairly inefficient 'rejection' approach (at least it will
> when I figure out how to reference individual cells).  Any ideas?  Thanks.
>

do you mean:
>>>a[1]
array([1,2,3])

    Charlie Boncelet
------
Charles Boncelet, University of Delaware,
On sabbatical at ADFA, Canberra Australia,
Home Page: http://www.ece.udel.edu/~boncelet/





More information about the Python-list mailing list