Matching matches between two numpy arrays

Let's say I have two arrays a and b:

a = np.arange(0,100).reshape(10,2,5)
b = np.arange(50,500).reshape(45,2,5)

      

I need to know how many of the 10 arrays in the arrays a

are in b

. The following function does the job, but it's not efficient enough:

def measure_overlap(array_1, array_2):
    co = 0
    for i in range(0, len(array_1)):
        if array_1[i] in array_2:
            co = co + 1
    return co

measure_overlap(a, b)
5

      

+3
python arrays numpy


source to share


No one has answered this question yet

See similar questions:

33
Get intersecting lines over two 2D numpy arrays

or similar:

7494
How can I remove a specific element from an array in JavaScript?
4380
For each by an array in JavaScript?
4268
How to combine two dictionaries in one expression?
3714
How to check if an array contains a value in JavaScript?
3393
Create ArrayList from array
3273
What is the difference between @staticmethod and @classmethod?
2895
How do I add something to the array?
2893
Looping through an array in JavaScript
2543
How can I check if an object is an array?
1531
Calling a module function using its name (string)



All Articles
Loading...
X
Show
Funny
Dev
Pics