I have a very large numpy array of matrix that has the structure:
np.array([
[[1, 2],
[3, 4]],
[[5, 6],
[7, 8]],
])
my expected output is
np.array([
[[1, 3],
[2, 4]],
[[5, 7],
[6, 8]],
])
I know methods using list comprehension or for loops and then create the numpy array again, but methods involving creating the numpy from list is too slow for my data. And vectorize seems to be only working on numbers.
When I use normal python lists or other languages, I can map the transpose function into the list, but it seems there is no similar function in numpy.
How can I do it efficiently?
swapaxes:arr.swapaxes(1,2)arr.transpose(0, 2, 1)?