Skip to content Skip to sidebar Skip to footer

Change 2d Array By 2d Array Of Indices

I have input array: np.random.seed(45) a = np.random.randint(100,size=(5,21)) print (a) [[75 30 3 32 95 61 85 35 68 15 65 14 53 57 72 87 46 8 53 12 34] [24 12 17 68 30 56 14 36

Solution 1:

Index into columns, permute axes and reshape -

c = a[:, b].swapaxes(0,1).reshape(-1,b.shape[1])

Post a Comment for "Change 2d Array By 2d Array Of Indices"