I have an array group which is Nx2:
array([[ 1, 6],
[ 1, 0],
[ 2, 1],
...,
[40196, 40197],
[40196, 40198],
[40196, 40199]], dtype=uint32)
and another array selection which is (M,):
array([3216, 3217, 3218, ..., 8039])
I want to create a new array containing all the rows of group where both elements are in selection. This is how I did it:
np.array([(i,j) for (i,j) in group if i in selection and j in selection])
This works, but I know there must be a more efficient way that takes advantage of some numpy function.