I want to compare two NumPy
arrays row-wise and return the number of same rows.
If i use the code below:
a=np.array([[1,2],[3,4]])
b=np.
What about something like this:
import numpy as np
a = np.array([['a', 'b'], ['c', 'd'],\
['e', 't'], ['a', 'b'], ['a', 'b']])
[['a' 'b']
['c' 'd']
['e' 't']
['a' 'b']
['a' 'b']]
b = np.array([['a','b'],['e','t'],['r','t']])
[['a' 'b']
['e' 't']
['r' 't']]
shared_rows=0
for row in b:
temp=a==row
shared_rows+=sum(np.sum(temp, axis=1)==a.shape[1])
print(shared_rows)
4