indexing question

Faheem Mitha faheem at email.unc.edu
Thu Mar 25 18:38:58 EST 2004


Dear People,

Suppose I create a numarray arry (say). A numeric array would be fine
too; it probably does not matter. 

>>>import numarray
>>>foo = numarray.reshape(numarray.arange(9),(3,3))
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [ 8,  9, 10, 11],
       [12, 13, 14, 15]])

Is there some way to select the indexes corresponding only to (say)
two rows or columns?

ie suppose I just want the first and the fourth row or the first and
third columns? Is there some clean way to do this which does not
involve extract individual rows or columns?

Ie. I want something like
>>> foo[?,:]
array([[ 0,  1,  2,  3],
       [12, 13, 14, 15]])

etc. 

Suggestions appreciated. Thanks in advance.

                                               Faheem.



More information about the Python-list mailing list