I've got a np array of arrays and I want to remove all elements that match a condition. I want to avoid for loops to try to make it faster.
The np array is of shape [N,2]. I want to remove all sub-arrays where the first element is equal to zero.
[[1,2],
[0,5], # <--- Remove
[5,1],
[0,3], # <--- Remove
[1,1],
[0,0], # <--- Remove
[5,0],
.....
[5,5]]
I hope there is a solution with just one line of code. I just can't figure this line out. I hope somebody can help me.
Thank you.
array[~(array[:,0] == 0)]this will do.