I have the following dataframe:
A B
0 1 5
1 2 6
2 3 7
3 4 8
I wish to calculate the covariance
a = df.iloc[:,0].values
b = df.iloc[:,1].values
Using numpy for cov as :
numpy.cov(a,b)
I get:
array([[ 1.66666667, 1.66666667],
[ 1.66666667, 1.66666667]])
Shouldn't the diagonal elements be 1? How do I get the diagonal elements to 1?