Home > Software engineering >  Taking away from numpy ndarray from another
Taking away from numpy ndarray from another

Time:07-12

I have two numpy.ndarrays which one is a random sample from the other. I wish to take the smaller one (random sample) and remove those data points from the larger one.

What is the code to do so?

  • delete and remove do not work on ndarrays

Thank you

CodePudding user response:

Maybe this can help:

a = np.array([1, 2, 3, 2, 4, 1])
b = np.array([3, 4, 5, 6])
np.setdiff1d(a, b) # array([1, 2])

From here.

  • Related