python pandas: how to calculate derivative/gradient

后端 未结 5 1964
野的像风
野的像风 2021-02-01 19:16

Given that I have the following two vectors:

In [99]: time_index
Out[99]: 
[1484942413,
 1484942712,
 1484943012,
 1484943312,
 1484943612,
 1484943912,
 1484944         


        
5条回答
  •  执笔经年
    2021-02-01 19:42

    As there is no builtin derivative method in Pandas Series / DataFrame you can use https://github.com/scls19fr/pandas-helper-calc.

    It will provide a new accessor called calc to Pandas Series and DataFrames to calculate numerically derivative and integral.

    So you will be able to simply do

    recv.calc.derivative()
    

    It's using diff() under the hood.

提交回复
热议问题