I have a np.array
stored in a variable, x
, which looks like below:
array([[ 956],
[ 929],
[1083],
[1074],
[ 922]]
I want to subtract every number from the previous number, and I want a new variable, y
, to look like below:
array([[ -27],
[ 154],
[ -9],
[-152]]
import numpy as np
x = np.array([[ 956],
[ 929],
[1083],
[1074],
[ 922]]
out = np.diff(out, axis=0)
Out: array([[ -27],
[ 154],
[ -9],
[-152]]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.