numpy.intersect1d

numpy.intersect1d(ar1, ar2)

Intersection returning repeated or unique elements common to both arrays.

Parameters:

ar1,ar2 : array_like

Input arrays.

Returns:

out : ndarray, shape(N,)

Sorted 1D array of common elements with repeating elements.

See also

intersect1d_nu
Returns only unique common elements.
numpy.lib.arraysetops
Module with a number of other functions for performing set operations on arrays.

Examples

>>> np.intersect1d([1,3,3],[3,1,1])
array([1, 1, 3, 3])

Previous topic

numpy.unique1d

Next topic

numpy.intersect1d_nu

This Page

Quick search