I have a 5D array 'a', size (3,2,2,2,2).
import numpy as np a = np.arange(48).reshape(3,2,2,2,2) a[0,0,0]: array([[0, 1], [2, 3]])
What I want to do is rotate this 5D array 180 degrees, but only in the last two dimensions, without changing their positions. Therefore, the output [0,0,0] should look like this:
out[0,0,0]: array([[3, 2], [1, 0]])
What I tried:
out = np.rot90(a, 2) out[0,0,0]: array([[40, 41], [42, 43]])
The rot90 function obviously rotates the entire array.
Note. I want to avoid using for loops if possible