2021-07-31

How to drop the all the 1's in a correlation matrix

I'm trying to change/eliminate the 1's that run diagonally in a correlation matrix so that when I take the average of the rows of the correlation matrix, the 1s don't affect the mean of each of the rows.

Let's say I have the dataset,

A B C D E F 45 49 49 65 65 45 60 62 63 80 80 60 80 82 83 100 100 80 80 100 123 122 120 80 39 52 43 60 50 65 58 64 58 80 65 80 78 84 78 109 85 100 78 130 111 130 85 100 78 104 78 159 115 100 44 48 65 50 64 43 59 63 80 65 80 58 79 83 100 85 105 78 79 103 120 135 115 78 45 30 35 20 20 45 50 20 55 25 25 30 60 45 50 90 80 70

When I do dfcorr = df.corr() dfcorr, I get

   A            B           C           D          E           F

A 1.000000 0.842125 0.834808 0.832773 0.844158 0.806787 B 0.842125 1.000000 0.847606 0.907595 0.818668 0.863645 C 0.834808 0.847606 1.000000 0.718199 0.804671 0.582033 D 0.832773 0.907595 0.718199 1.000000 0.884236 0.878421 E 0.844158 0.818668 0.804671 0.884236 1.000000 0.718668 F 0.806787 0.863645 0.582033 0.878421 0.718668 1.000000

I want all the 1's to be dropped so that if I want to take the mean of each of the rows, the 1's won't affect them.



from Recent Questions - Stack Overflow https://ift.tt/3idyTRx
https://ift.tt/eA8V8J

No comments:

Post a Comment