I have recently discovered numpy.ediff1d
Is there an advantage of using numpy.ediff1d
instead of numpy.diff
or what is it's usecase?
Prior to numpy 1.16.0
, one could use ediff1d(ar, to_end, to_begin)
to pad the result of ar[1:] - ar[-1:]
. But from 1.16.0
diff()
supports padding and covers all of ediff1d()
functionality and much more. Also, diff()
has same performance in most cases and outperforms ediff1d()
for boolean arrays.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With