I have a df, self.meter_readings, where the index is datetime values and there is a column of numbers, as below:
self.meter_readings['PointProduction']
2012-03     7707.443
2012-04     9595.481
2012-05     5923.493
2012-06     4813.446
2012-07     5384.159
2012-08     4108.496
2012-09     6370.271
2012-10     8829.357
2012-11     7495.700
2012-12    13709.940
2013-01     6148.129
2013-02     7249.951
2013-03     6546.819
2013-04     7290.730
2013-05     5056.485
Freq: M, Name: PointProduction, dtype: float64
I want to get the gradient of PointProduction against time. i.e. y=PointProduction x=time. I'm currently trying to obtain m using a linear regression:
 m,c,r,x,y = stats.linregress(list(self.meter_readings.index),list(self.meter_readings['PointProduction']))
However I am getting an error:
 raise TypeError(other).
This is seemingly due to the formation of the x-axis as timestamps as oppose to just numbers.
How can I correct this?
 
     
     
    