I've got a sparse, symmetric array and I'm trying to delete a row and column of that array if all the individual entries of a given row (and column) do not satisfy some threshold condition. For example if
min_value = 2
a = np.array([[2, 2, 1, 0, 0],
[2, 0, 1, 4, 0],
[1, 1, 0, 0, 1],
[0, 4, 0, 1, 0],
[0, 0, 1, 0, 0]])
I would like to keep the rows (and columns) where the it has at least a value of 2 or more, so that with the above example this would yield
a_new = np.array([2, 2, 0],
[2, 0, 4],
[0, 4, 1]]
So I would lose rows 3 and 5 (and columns 3 and 5) since every entry is less then 2. I've had a look at How could I remove the rows of an array if one of the elements of the row does not satisfy a condition?, Delete columns based on repeat value in one row in numpy array and Delete a column in a multi-dimensional array if all elements in that column satisfy a condition but the marked solutions do not fit what I'm attempting to accomplish.
I was thinking of performing something similar to:
a_new = []
min_count = 2
for row in a:
for i in row:
if i >= min_count:
a_new.append(row)
print(items)
print(temp)
but this doesn't work since it doesn't delete a bad column and if there are two (or more) instances where a value is greater then the threshold it append a row multiple times.