I was viewing this page with some numpy exercises. Exercise 65 goes like this:
Consider two arrays A and B of shape (8,3) and (2,2). How to find rows of A that contain elements of each row of B regardless of the order of the elements in B ?
# Author: Gabe Schwartz
A = np.random.randint(0,5,(8,3))
B = np.random.randint(0,5,(2,2))
C = (A[..., np.newaxis, np.newaxis] == B)
rows = (C.sum(axis=(1,2,3)) >= B.shape[1]).nonzero()[0]
print(rows)
Can someone explain to me what A[..., np.newaxis, np.newaxis]
is doing? I've never seen ...
in python, ever.
On a separate note, what does ...
normally do in python?