I have 2 numpy arrays and I wanted to select a subset of rows in one of them based on a conditional subset of the other
arr1 = np.array([[1, 2, 1, 5], [3, 4, 1, 6], [2, 2, 2, 7]])
arr2 = np.array([[2, 2, 1], [2, 3, 0], [2, 1, 1]])
I want to select only those rows in arr1 where the 3rd element in arr2 is 1. In this case, arr2 will look like so:
np.array([[2, 2, 1], [2, 1, 1]]) and arr1 will become: np.array([[1, 2, 1, 5], [2, 2, 2, 7]]). Both of them can be assumed to have the same number of rows, but can have different number of columns. How can I achieve this?