I'm trying to find the difference between the 2 arrays
arrayA = np.array(['A1', 'A2', 'A3'])
arrayB = np.array(['A1', 'A2', 'A3', 'A4', 'A5', 'A6'])
I'm trying to get
difference = ['A4', 'A5', 'A6']
How can I do this? Thank you.
Use numpy's setdiff:
np.setdiff1d(arrayA, arrayB)
Also - is there any special reason for which this needs to be a numpy array? You could simply use sets and then the minus operator: set(arrayA) - set(arrayB)
[i for i in arrayB if i not in arrayA]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With