I'm trying to use numpy to remove rows from a two dimensional array where the first value of the row (so the element at index 0) does not match a certain condition.
I am able to do this with regular python using two loops, but I would like to do it more efficiently with numpy, e.g. with numpy.where
I have been trying various things with numpy.where
and numpy.delete
but I struggle with the fact that I want to select rows by using a condition that only needs to be verified by the first element, and not the second (I dont care about the value of the second element)
Here is an example where I only want to keep the rows where the first value of each row is 6.
Input:
[[0,4],
[0,5],
[3,5],
[6,8],
[9,1],
[6,1]]
Output:
[[6,8],
[6,1]]