I have an array in python made like this:
array([ 18, 36, 54, ..., 9893804, 9893822, 9893840],
dtype=int64)
I wish to obtain an array containing the "distances" bewteen ech byte...
in this case it would be: [18,18,18, ..., xxx, 18, 18]
to do that I use an ugly for i in range(len(arr))
I suspect there is a way by using np.flatnonzero(something) I could not find it.. any clue?
CodePudding user response:
How about np.diff(arr)
?
arr = np.array(...)
print(np.diff(arr)) # [18 18 18 ... 18 18 18]