I would like to use the pandas OLS function to match the trend line for my data series. Does anyone know how to use the pandas series datetime index as a predictor in OLS?
For example, suppose I have a simple time series:
>>> ts 2001-12-31 19.828763 2002-12-31 20.112191 2003-12-31 19.509116 2004-12-31 19.913656 2005-12-31 19.701649 2006-12-31 20.022819 2007-12-31 20.103024 2008-12-31 20.132712 2009-12-31 19.850609 2010-12-31 19.290640 2011-12-31 19.936210 2012-12-31 19.664813 Freq: A-DEC
I would like to do OLS on it using the index as a predictor:
model = pd.ols(y=ts,x=ts.index,intercept=True)
But since x is a datetime index list, the function returns an error. Anyone have an idea?
I could use linregress from scipy.stats, but I am wondering if this is possible with Pandas.
Thanks Greg
leroygr
source share