numpy.ma.ediff1d() function in Python Last Updated : 12 Nov, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 : [array_like, optional] Number to prepend at the beginning of the returned differences. Return : Return the differences between consecutive elements of an array. Code #1: Python3 # Python program explaining # numpy.ma.ediff1d() function # importing numpy as geek import numpy as geek arr = geek.array([3, 5, 8, 4, 12]) gfg = geek.ma.ediff1d(arr) print(gfg) Output: [ 2 3 -4 8] Code #2: Python3 # Python program explaining # numpy.ma.ediff1d() function # importing numpy as geek import numpy as geek arr = geek.array([3, 5, 8, 4, 12]) gfg = geek.ma.ediff1d(arr, to_begin=geek.array([-23, 0]), to_end=25) print(gfg) Output: [-23 0 2 3 -4 8 25] Comment More infoAdvertise with us Next Article Python | Numpy np.ediff1d() method C code_hunt Follow Improve Article Tags : Python Python-numpy Python numpy-Mathematical Function Practice Tags : python Similar Reads Numpy matrix.I function | Python With the help ofnumpy.matrix.I() function we can get the multiplicative inverse of the same size as of our given matrix. Syntax : numpy.matrix.I() Return : [matrix object] If self is non-singular, ret is such that ret * self == self * ret == np.matrix(np.eye(self[0, :].size) all return True. Return 1 min read numpy.i0() function | Python numpy.i0() function is the modified Bessel function of the first kind, order 0. it's usually denoted by I0. Syntax : numpy.i0(x) Parameters : x : [array_like, dtype float or complex] Argument of the Bessel function. Return : [ndarray, shape = x.shape, dtype = x.dtype] The modified Bessel function ev 1 min read Python | Numpy np.ediff1d() method 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 1 min read numpy.finfo() function â Python numpy.finfo() function shows machine limits for floating point types. Syntax : numpy.finfo(dtype) Parameters : dtype : [float, dtype, or instance] Kind of floating point data-type about which to get information. Return : Machine parameters for floating point types. Code #1 : Python3 # Python program 1 min read numpy.ma.mask_cols() function | Python In thisnumpy.ma.mask_cols() function, mask columns of a 2D array that contain masked values. This function is a shortcut to mask_rowcols with axis equal to 1. Syntax : numpy.ma.mask_cols(arr, axis = None) Parameters : arr : [array_like, MaskedArray] The array to mask. axis : [int, optional] Axis alo 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 Like