[Numpy-discussion] indexing question
Faheem Mitha
faheem at email.unc.edu
Sat Mar 27 09:06:05 CST 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 extracting individual rows or columns?
Ie. I want something like
>>> foo[?,:]
array([[ 0, 1, 2, 3],
[12, 13, 14, 15]])
etc.
Suggestions appreciated. Please cc me; I'm not subscribed. Thanks in
advance.
Faheem.
More information about the Numpy-discussion
mailing list