Python | Numpy np.ediff1d() method Last Updated : 02 Dec, 2019 Summarize Comments Improve Suggest changes Share Like Article Like Report With the help of np.ediff1d() method, we can get the 1D array of differences between two consecutive elements by using np.ediff1d() method. Syntax : np.ediff1d(array) Return : Return 1D array having differences of consecutive elements. Example #1 : In this example we can see that by using np.ediff1d() method, we are able to get the 1D array of consecutive differences of the elements of an array using this method. Python3 1=1 # import numpy import numpy as np # using np.ediff1d() method arr = np.array([1, 2, 3, 5, 7, 11]) gfg = np.ediff1d(arr) print(gfg) Output : [1 1 2 2 4] Example #2 : Python3 1=1 # import numpy import numpy as np # using np.ediff1d() method arr = np.array([1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47]) gfg = np.ediff1d(arr) print(gfg) Output : [1 1 2 2 4 2 4 2 4 6 2 6 4 2 4] Comment More infoAdvertise with us Next Article numpy.ma.ediff1d() function in Python J jitender_1998 Follow Improve Article Tags : Python Python-numpy Practice Tags : python Similar Reads Python | Numpy np.hermeone() method With the help of np.hermeone() method, we can use hermeone instead of np.ones() by using np.hermeone() method. Syntax : np.hermeone Return : Return the array of ones. Example #1 : In this example we can see that by using np.hermeone() method, we are able to get the functionality of np.ones as same a 1 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 numpy.diff() in Python numpy.diff() calculate the n-th discrete difference along the specified axis. It is commonly used to find differences between consecutive elements in a NumPy array, such as in time series or signal data. Example:Pythonimport numpy as np a = np.array([1, 2, 4, 7, 0]) res = np.diff(a) print(res)Output 3 min read Numpy np.unique() method-Python numpy.unique() finds the unique elements of an array. It is often used in data analysis to eliminate duplicate values and return only the distinct values in sorted order. Example:Pythonimport numpy as np a = np.array([1, 2, 2, 3, 4, 4, 4]) res = np.unique(a) print(res)Output[1 2 3 4] Explanation: nu 2 min read numpy.atleast_1d() in Python numpy.atleast_1d()function is used when we want to Convert inputs to arrays with at least one dimension. Scalar inputs are converted to 1-dimensional arrays, whilst higher-dimensional inputs are preserved. Syntax : numpy.atleast_1d(*arrays) Parameters : arrays1, arrays2, ... : [array_like] One or mo 2 min read numpy.linalg.eig() Method in Python In NumPy we can compute the eigenvalues and right eigenvectors of a given square array with the help of numpy.linalg.eig(). It will take a square array as a parameter and it will return two values first one is eigenvalues of the array and second is the right eigenvectors of a given square array. Syn 1 min read Like