numpy.union1d(ar1, ar2)
[source]
Find the union of two arrays.
Return the unique, sorted array of values that are in either of the two input arrays.
Parameters: |
|
---|---|
Returns: |
|
See also
numpy.lib.arraysetops
>>> np.union1d([-1, 0, 1], [-2, 0, 2]) array([-2, -1, 0, 1, 2])
To find the union of more than two arrays, use functools.reduce:
>>> from functools import reduce >>> reduce(np.union1d, ([1, 3, 4, 3], [3, 1, 2, 1], [6, 3, 4, 2])) array([1, 2, 3, 4, 6])
© 2005–2019 NumPy Developers
Licensed under the 3-clause BSD License.
https://docs.scipy.org/doc/numpy-1.17.0/reference/generated/numpy.union1d.html