If I have a numpy array for example :
A = np.array([[3, 2], [2, -1], [2, 3], [5, 6], [7,-1] , [8, 9]])
I would like to separate the part of the array with the subarrays having -1 from the ones who don't. Keep in mind that I'm working on very big data set, so every operation can be very long so I try to have the most effective way memory and CPU-time wise.
What I am doing for the moment is :
slicing1 = np.where(A[:, 1] == -1)
with_ones = A[slicing1]
slicing2 = np.setdiff1d(np.arange(A.shape[0]), slicing1, assume_unique=True)
without_ones = A[slicing2]
Is there a way to not create the slicing2 list to decrease the memory consumption as it can be very big?
Is there a better way to approach the problem?