Advertisement

Python数组实现相邻元素相减:计算差值

阅读量:

可通过使用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>

全部评论 (0)

还没有任何评论哟~