This is how you extract elements
>>> from numpy import *
>>> stuff=arange(8).reshape(4,2)
>>> stuff
array([[0, 1],
[2, 3],
[4, 5],
[6, 7]])
>>> extract(stuff>4,stuff)
array([5, 6, 7])
This is how you extract elements from an array by the index of another
>>> a [1, 2, 3] >>> b [3, 4, 5] >>> barr=array(b) >>> aarr=array(a) >>> extract(aarr>1,barr) array([4, 5])
No comments:
Post a Comment