I am interested to calculated the cross correlation between two columns in a table, the index is the date. I would like to know what is the lag at the best cross-correlation value.
I am using this: dataframe1.corr(dataframe2, method='pearson',min_periods=1)
For example in matlab, one could do: [r,lags] = xcorr(x,y), and lags is a vector with the lags at which the correlations are computed. I would like to get the same thing with pandas. The dataframe.corr only outputs the cross-correlation value between 2 columns.
dataframe1:
1994-10-31 0
1994-11-30 23604
1994-12-31 1880
1995-01-31 24566
....
2017-07-31 2224
dataframe2:
1994-10-31 0
1994-11-30 0
1994-12-31 36997
1995-01-31 7444
....
2017-07-31 9711
I want to know how much is dataframe2 shifted, in order to give the maximum cross correlation value.