Python Practice › NumPy Programs › Program 57
Union of two arrays
Write a NumPy program to find the union of two arrays.
Input
[56, 18, 28, 36], [76, 36, 56]
Output
[18 28 36 56 76]
Approach
np.union1d.
Solution
import numpy as npprint(np.union1d([56, 18, 28, 36], [76, 36, 56]))Output
[18 28 36 56 76]
Learn the concept
New to this topic? Read the lesson, then come back.