By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,532 Members | 1,495 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,532 IT Pros & Developers. It's quick & easy.

indexing question

P: n/a
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.
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Faheem Mitha wrote:
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.


Faheem,
On the following like, I see something like what you
want.

http://matpy.sourceforge.net/MatPy/node3.html

wes

Jul 18 '05 #2

P: n/a
On Fri, 26 Mar 2004 16:32:32 GMT, wes weston <ww*****@att.net> wrote:
Faheem,
On the following like, I see something like what you
want.

http://matpy.sourceforge.net/MatPy/node3.html


Yes, I realise that I can take slices as long as the corresponding
rows and columns are contiguous. My question is, how can I make a
subarray from rows or columns that are *not* contiguous? If this is
possible, can you show me an example?

Faheem.
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.