Derivative of Panda Series in Python using Scipy.misc

62lalag4  于 2022-11-10  发布在  Python
关注(0)|答案(1)|浏览(94)

I have data in CSV file, I am extracting data using iloc into variables. So I have 2 series one is the data and the other is time. I want to derivate the data with respect to time and then plot the Derivate data.

DY=misc.derivative(YR,TR)
plt.plot(DY)
plt.show()

I am getting this errorTypeError: 'Series' object is not callableYR and TR are Panda Series I am getting this output by print(YR) and Print(TR)

0           0
1          10
2          20
3          30
4          40
        ...  
3758    37578
3759    37588
3760    37598
3761    37608
3762    37618
Name: timestamp, Length: 3763, dtype: int64

0      -79.488485
1      -79.451540
2      -79.413175
3      -79.379011
4      -79.339471
          ...    
3758   -79.430326
3759   -79.498313
3760   -79.574641
3761   -79.664465
3762   -79.776534
Name: Y, Length: 3763, dtype: float64
x33g5p2x

x33g5p2x1#

Look at the function signature of misc.derivative: https://docs.scipy.org/doc/scipy/reference/generated/scipy.misc.derivative.html
The first argument is a callable, which is why you get the Series not callable error. Scipy.misc.derivative seems to be used for evaluating derivatives of an analytical function numerically, which is not what you are attempting to do. It seems like you want to do some stenciling to approximate derivatives instead.

相关问题