1

Assume that:

numpy array A is

[[1,2,3,4]
 [8,4,4,4]]

numpy array B is

[[1,2,3,4]
 [5,2,4,7]]

the intersection is

[[1,2,3,4]]

and the type is float64, how to calculate intersection using the numpy?

my poor solution:

inter = []
for item in A.tolist():
    if item in B.tolist():
        inter.append(item)
inter = numpy.array(inter)

but i dont think this is a good solution,and i wonder the method make loss on precision?

cs95
  • 379,657
  • 97
  • 704
  • 746
unsky
  • 51
  • 6

0 Answers0