Coding hierarchy Coding hierarchy - 1 month ago 19
Python Question

Selecting non 1. values in iteration of a data-set while calculating coefficient correlation?

I'm iterating through the result set of the calculation of correlation values.

The output of this loop:

for x in range(DT.shape[1]):
print np.corrcoef(DT[:, x], YDT, rowvar=False)


Is the following:

[[ 1. ,0.58889117],
[ 0.58889117 ,1. ]]
[[ 1. ,0.69343965],
[ 0.69343965 ,1. ]]
[[ 1. ,0.52252876],
[ 0.52252876 ,1. ]]
[[ 1. ,0.65612867],
[ 0.65612867 ,1. ]]
[[ 1. ,0.67349517],
[ 0.67349517 ,1. ]]
[[ 1. ,0.5557239],
[ 0.5557239 ,1. ]]
[[ 1. ,0.69473707],
[ 0.69473707 ,1. ]]
[[ 1. ,0.71186044],
[ 0.71186044 ,1. ]]


How can I select the values that are not 1. from the first row? Also, how can I not print each row twice....meaning the first row is [1. 0.58888] and the second one is [0.58888 1.]

For each iteration, I want the decimal values, not the 1's values...without duplication.

I greatly appreciate your help.

Answer Source

The comment by Divakar above provided the solution.

np.corrcoef(DT[:, x], YDT, rowvar=False)[0,1]