Reputation: 41
I have a symmetric matrix and I am curious if it is possible to only search the upper triangle portion of the matrix using np.where. That is, is there a way to either delete the lower triangular portion of the matrix using a loop or a function so I can search the upper triangular portion of the matrix with np.where?
Upvotes: 0
Views: 153
Reputation: 3603
import numpy as np
a = np.array([[1 ,0.42, 0.78], [0.42, 1, 0.73], [0.78, 0.73, 1]])
# k=1 excludes diagonal correlation is 1
np.where(np.triu(a > 0.7, k=1))
Upvotes: 1