可以借助np.diff
实现,示例如下:
>>> x = np.array([1, 2, 4, 7, 0])
>>> np.diff(x)
array([ 1, 2, 3, -7])
numpy官方文档:https://numpy.org/doc/stable/reference/generated/numpy.diff.html
可以借助np.diff
实现,示例如下:
>>> x = np.array([1, 2, 4, 7, 0])
>>> np.diff(x)
array([ 1, 2, 3, -7])
numpy官方文档:https://numpy.org/doc/stable/reference/generated/numpy.diff.html