I want to calculate the delay length autocorrelation coefficients of one of the Pandas DataFrame columns. Excerpt from my data:
RF PC CD PN DN P year 1890 NaN NaN NaN NaN NaN NaN NaN 1891 -0.028470 -0.052632 0.042254 0.081818 -0.045541 0.047619 -0.016974 1892 -0.249084 0.000000 0.027027 0.067227 0.099404 0.045455 0.122337 1893 0.653659 0.000000 0.000000 0.039370 -0.135624 0.043478 -0.142062
Along the year , I want to calculate the lag autocorrelation, one for each column ( RF , PC , etc.).
To calculate autocorrelation, I selected two time series for each column, whose start and end data differed by one year, and then calculated the correlation coefficients with numpy.corrcoef .
For example, I wrote:
numpy.corrcoef(data[['C']][1:-1],data[['C']][2:])
(the entire DataFrame is called data ).
However, the team, unfortunately, returned:
array([[ nan, nan, nan, ..., nan, nan, nan], [ nan, nan, nan, ..., nan, nan, nan], [ nan, nan, nan, ..., nan, nan, nan], ..., [ nan, nan, nan, ..., nan, nan, nan], [ nan, nan, nan, ..., nan, nan, nan], [ nan, nan, nan, ..., nan, nan, nan]])
Can someone kindly advise me how to calculate autocorrelation?