[Numpy-discussion] extract elements of an array that are contained in another array?
Wed Jun 3 19:45:10 CDT 2009
On Wed, Jun 3, 2009 at 8:29 PM, Ning Sean <email@example.com> wrote:
> Hi, I want to extract elements of an array (say, a) that are contained in
> another array (say, b). That is, if a=array([1,1,2,3,3,4]), b=array([1,4]),
> then I want array([1,1,4]).
> I did the following but the speed is very slow (maybe because a is very
> for x in b:
> any way to speed it up?
It's waiting in Trac for inclusion in numpy
The current version only handles arrays with unique elements.
You can copy the ticket attachment, the version there is very fast.
More information about the Numpy-discussion