numpy.setdiff1d() function in Python Last Updated : 17 May, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report numpy.setdiff1d() function find the set difference of two arrays and return the unique values in arr1 that are not in arr2. Syntax : numpy.setdiff1d(arr1, arr2, assume_unique = False) Parameters : arr1 : [array_like] Input array. arr2 : [array_like] Input comparison array. assume_unique : [bool] If True, the input arrays are both assumed to be unique, which can speed up the calculation. Default is False. Return : [ndarray] 1D array of values in arr1 that are not in arr2. The result is sorted when assume_unique = False, but otherwise only sorted if the input is sorted. Code #1 : Python3 # Python program explaining # numpy.setdiff1d() function # importing numpy as geek import numpy as geek arr1 = [5, 6, 2, 3, 4] arr2 = [1, 2, 3] gfg = geek.setdiff1d(arr1, arr2) print (gfg) Output : [4 5 6] Code #2 : Python3 # Python program explaining # numpy.setdiff1d() 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, 11, 13, 15] gfg = geek.setdiff1d(arr1, arr2) print (gfg) Output : [2 4 6 8] Comment More infoAdvertise with us Next Article numpy.in1d() 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.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 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.ma.ediff1d() function in Python numpy.ma.ediff1d() function return the differences between consecutive elements of an array. Syntax : numpy.ma.ediff1d(arr, to_end = None, to_begin = None) Parameters : arr : [array_like] Input array. to_end : [array_like, optional] Number to append at the end of the returned differences. to_begin 1 min read id() function in Python In Python, id() function is a built-in function that returns the unique identifier of an object. The identifier is an integer, which represents the memory address of the object. The id() function is commonly used to check if two variables or objects refer to the same memory location. Python id() Fun 3 min read Numpy - String Functions & Operations NumPy String functions belong to the numpy.char module and are designed to perform element-wise operations on arrays. These functions can help to handle and manipulate string data efficiently.Table of ContentString OperationsString Information String Comparison In this article, weâll explore the var 5 min read numpy.left_shift() in Python numpy.left_shift() function is used to Shift the bits of an integer to the left. The bits are shifted to the left by appending arr2 0s(zeroes) at the right of arr1. Since the internal representation of numbers is in binary format, this operation is equivalent to multiplying arr1 by 2**arr2. For exam 2 min read Like