bundles / numpy latest / numpy / ediff1d
_ArrayFunctionDispatcher
numpy:ediff1d
source: /dev/numpy/build-install/usr/lib/python3.14/site-packages/numpy/lib/_arraysetops_impl.py :40
Signature
def ediff1d ( ary , to_end = None , to_begin = None ) Summary
The differences between consecutive elements of an array.
Parameters
ary: array_likeIf necessary, will be flattened before the differences are taken.
to_end: array_like, optionalNumber(s) to append at the end of the returned differences.
to_begin: array_like, optionalNumber(s) to prepend at the beginning of the returned differences.
Returns
ediff1d: ndarrayThe differences. Loosely, this is
ary.flat[1:] - ary.flat[:-1].
Notes
When applied to masked arrays, this function drops the mask information if the to_begin and/or to_end parameters are used.
Examples
import numpy as np x = np.array([1, 2, 4, 7, 0]) np.ediff1d(x)✓
np.ediff1d(x, to_begin=-99, to_end=np.array([88, 99]))
✓y = [[1, 2, 4], [1, 6, 24]] np.ediff1d(y)✓
See also
- diff
- gradient
Aliases
-
numpy.ediff1d