What I have so far is:
dict={'A':[1,2,3], 'B':[2,5,4], 'C':[2,1,8]}
N=len(keys)
m=numpy.zeros(N,N)
for i in range(N):
for j in range(N):
m[i-1,j-1]=covariance(values[i-1],values[j-1])
m[j-1,i-1]=covariance(values[j-1],values[i-1])
m=numpy.triu(m)
which gives me:
1 0.639 0.07
0 1 0.51
0 0 1
I dont have the column names or the row names yet. I would like something like this:
A B C
A 1 0.639 0.07
B 0 1 0.51
C 0 0 1
Given this matrix, I would like to sort it in descending order by the value of the matrix so the output I would like is:
A & A: 1
B & B: 1
C & C: 1
A & B: 0.639
B & C: 0.51
A & C: 0.07
B & A: 0 #etc
From the output would like to save it into a csv file where the first column are the names and the second column are the corresponding scores
Thanks for reading.
sorted()function using thekeyparameter.