[Numpy-discussion] extract elements of an array that are contained in another array?
Alan G Isaac
aisaac at american.edu
Thu Jun 4 11:12:17 EDT 2009
> On Thu, Jun 4, 2009 at 10:13 AM, Alan G Isaac <aisaac at american.edu> wrote:
>> Or if a stable order is not important (I don't
>> recall if the OP specified), one could just
>> np.intersect1d(a, np.unique(b))
On 6/4/2009 10:50 AM josef.pktd at gmail.com apparently wrote:
> This requires that also `a` has only unique elements.
> intersect1d_nu doesn't require unique elements.
array([1, 1, 2, 3, 3, 4])
>>> np.intersect1d(a, np.unique(b))
array([1, 1, 3, 4])
(And thus my question about intersect1d...)
More information about the NumPy-Discussion