I have a 2d numpy array like so, which will only ever have 0, 1 values.
a = np.array([[1, 0, 1, 0], # Indexes 0 and 2 == 1
[0, 1, 1, 0], # Indexes 1 and 2 == 1
[0, 1, 0, 1], # Indexes 1 and 3 == 1
[0, 1, 1, 1]]) # Indexes 1, 2, and 3 == 1
What I'd like to do is to get the indices of every row where a pair of column indexes passed are all equal to 1.
For example, if the function doing this is get_rows, get_rows(a, [1, 3]), should return [2, 3], because the rows at indexes 2 and 3 have column indexes 1 and 3 equal to 1. Similarly, get_rows(a, [1, 2]) should return [1, 3].
I know how to do this in a Pandas dataframe, but I'd like to stick to using pure numpy for this one. I tried using np.where in some form like
np.where( ((a[i1 - 1] == 1) & (a[i2 - 1] == 1) ))
but this doesn't seem to give me what I want, and wouldn't work for varying number of passed indices.