Using Numpy, I am cross correlating two large data sets (of different lengths), as part of a method to compare the similarity of the data. However to take the data onto the next step of the comparison I want to "align" the data such that when cross correlated the lag position is 0.

So far what I have tried is finding the lag position of the original cross correlation and then using pandas.DataFrame.shift() to shift the data such that the lag is cancelled out by the "shifting". This gives drastically different results than expected and are totally unrelated to how many indexes the data is shifted.

What I am aiming for is, after manipulation, when the data sets are cross-correlated again, the corresponding lag to be 0.

Any help would be much appreciated!


1 Answer 1


After the first cross-correlation the lag position of the cross-correlation of those two data sets will be returned. If the original data set is then shifted acording to this lag position and a cross-correlation run again in effect to new data sets are being cross-correlated. As long as the "shifting" of the data takes place correctly the data set will be aligned as desired.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.