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
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.
[1 1 2 2 4]
Example #2 :
[1 1 2 2 4 2 4 2 4 6 2 6 4 2 4]
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course