I have two 2D numpy arrays
a = [[1,2,3], [3,4,5]] b = [[1,2,3], [3,4,5], [6,7,8]]
How do I do b-a as in remove rows in b that are found in a?
The answer I need is c = [[6,7,8]]
Thank you!
I have two 2D numpy arrays
a = [[1,2,3], [3,4,5]] b = [[1,2,3], [3,4,5], [6,7,8]]
How do I do b-a as in remove rows in b that are found in a?
The answer I need is c = [[6,7,8]]
Thank you!
for i in range(len(a)):
for j in range(len(b)):
if(b[j] == a[i]):
b.pop(j)
I think this should solve your problem.
You can use list comprehension here:
a = [[1,2,3], [3,4,5]]
b = [[1,2,3], [3,4,5], [6,7,8]]
result = [x for x in b if x not in a]
print(result)
Output :
[[6, 7, 8]]