Let A be the following array
A = np.array([[2, 1, 2, 2],
[1, 4, 0, 3],
[0, 0, 3, 4],
[3, 3, 1, 0],
[4, 2, 4, 1]])
and let M be the following boolean mask
M = np.array([[ True, False, False, False],
[ True, False, False, False],
[False, True, False, True],
[ True, True, False, False],
[False, True, True, False]])
Question 1:
How can I get the indices of the last N elements in each column of A such that they are False in the mask M?
In other words, I would like to get indices (for N = 2)
row_ixs = [2, 4, 0, 1, 2, 3, 3, 4]
col_ixs = [0, 0, 1, 1, 2, 2, 3, 3]
Question 2:
How can I get the indices of the elements in each column of A that are not among the first N elements of A that are also False in the mask M?
In other words, I would like to get indices (for N = 2)
row_ixs = [2, 3, 3, 4]
col_ixs = [2, 2, 3, 3]
You can use:
Output:
steps
question #2
Output: