numpy.ediff1d(ary, to_end=None, to_begin=None)
[source]
The differences between consecutive elements of an array.
Parameters: |
|
---|---|
Returns: |
|
When applied to masked arrays, this function drops the mask information if the to_begin
and/or to_end
parameters are used.
>>> x = np.array([1, 2, 4, 7, 0]) >>> np.ediff1d(x) array([ 1, 2, 3, -7])
>>> np.ediff1d(x, to_begin=-99, to_end=np.array([88, 99])) array([-99, 1, 2, ..., -7, 88, 99])
The returned array is always 1D.
>>> y = [[1, 2, 4], [1, 6, 24]] >>> np.ediff1d(y) array([ 1, 2, -3, 5, 18])
© 2005–2019 NumPy Developers
Licensed under the 3-clause BSD License.
https://docs.scipy.org/doc/numpy-1.17.0/reference/generated/numpy.ediff1d.html