I have two 2d numpy arrays X and Y that look like:
X = np.array([[1,2,3,4],[4,5,6,7],[4,3,2,1],[7,8,9,0]]
)
Y = np.array([[0,0,0],[1,2,4],[1,1,1], [0,0,0]]
)
I want to remove all the arrays in Y that are all 0's (i.e. np.zeros), and all the corresponding arrays at the same index in the X array.
So, for these two X,Y arrays, I'd like back:
X = np.array([[4,5,6,7],[4,3,2,1]]
)
Y = np.array([[1,2,4],[1,1,1]]
)
X and Y will always have the same length, and X and Y will always be rectangular (i.e. every array within X will have the same length, and every array within Y will have the same length).
I tried using a loop but that doesn't seem to be as effective for large X and Y