Search code examples
python-3.xcross-correlationpearson-correlation

Pearson correlation in python data.corr()


I have a matrix with the following shape (20, 17) with rows being the time and columns the number of variables.

When i compute the correlation matrix using data.corr() naturally i get a (17 , 17) matrix.

My questions:

Is there a way to normalise the variables directly within the .corr() function? (i know i can do that before hand and then apply the function)

My correlation matrix is large and I have trouble viewing everything in one go (i have to scroll down to do the necessary comparison). Is there a way to present the results in a concise way (like a heat map) where i can easily spot the highest from the lowest correlation?

Many Thanks


Solution

  • You could use matplotlib's imshow() to see a heatmap of any matrix.

    Also, consider using pandas dataframes, this way you could sort by correlation strength and keep the labels of each row and col.