简体   繁体   中英

Taking away from numpy ndarray from another

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

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM