numpy.intersect1d() function in Python Last Updated : 17 May, 2020 Comments Improve Suggest changes Like Article Like Report numpy.intersect1d() function find the intersection of two arrays and return the sorted, unique values that are in both of the input arrays. Syntax: numpy.intersect1d(arr1, arr2, assume_unique = False, return_indices = False) Parameters : arr1, arr2 : [array_like] Input arrays. assume_unique : [bool] If True, the input arrays are both assumed to be unique, which can speed up the calculation. Default is False. return_indices : [bool] If True, the indices which correspond to the intersection of the two arrays are returned. The first instance of a value is used if there are multiple. Default is False. Return : [ndarray] Sorted 1D array of common and unique elements. Code #1 : Python3 # Python program explaining # numpy.intersect1d() function # importing numpy as geek import numpy as geek arr1 = geek.array([1, 1, 2, 3, 4]) arr2 = geek.array([2, 1, 4, 6]) gfg = geek.intersect1d(arr1, arr2) print (gfg) Output : [1 2 4] Code #2 : Python3 # Python program explaining # numpy.intersect1d() function # importing numpy as geek import numpy as geek arr1 = [1, 2, 3, 4, 5, 6, 7, 8, 9] arr2 = [1, 3, 5, 7, 9] gfg = geek.intersect1d(arr1, arr2) print (gfg) Output : [1 3 5 7 9] Comment More infoAdvertise with us Next Article numpy.intersect1d() function in Python S sanjoy_62 Follow Improve Article Tags : Machine Learning Python-numpy Python numpy-arrayManipulation python Practice Tags : Machine Learningpython Similar Reads numpy.in1d() function in Python numpy.in1d() function test whether each element of a 1-D array is also present in a second array and return a boolean array the same length as arr1 that is True where an element of arr1 is in arr2 and False otherwise. Syntax : numpy.in1d(arr1, arr2, assume_unique = False, invert = False) Parameters 2 min read numpy.interp() function - Python numpy.interp() function returns the one-dimensional piecewise linear interpolant to a function with given discrete data points (xp, fp), evaluated at x. Syntax : numpy.interp(x, xp, fp, left = None, right = None, period = None) Parameters : x : [array_like] The x-coordinates at which to evaluate the 2 min read numpy.mask_indices() function | Python numpy.mask_indices() function return the indices to access (n, n) arrays, given a masking function. Syntax : numpy.mask_indices(n, mask_func, k = 0) Parameters : n : [int] The returned indices will be valid to access arrays of shape (n, n). mask_func : [callable] A function whose call signature is s 1 min read numpy.union1d() function in Python numpy.union1d() function find the union of two arrays and return the unique, sorted array of values that are in either of the two input arrays. Syntax : numpy.union1d(arr1, arr2) Parameters : arr1, arr2 : [array_like] Input arrays. Return : [ndarray] Unique, sorted union of the input arrays. Code #1 1 min read numpy.setxor1d() function in Python numpy.setxor1d() function find the set exclusive-or of two arrays and return the sorted, unique values that are in only one (not both) of the input arrays. Syntax : numpy.setxor1d(arr1, arr2, assume_unique = False) Parameters : arr1, arr2 : [array_like] Input arrays. assume_unique : [bool] If True, 1 min read Like