Reshape an array in NumPy
a = np.arange(18).reshape(9,2) b = a.reshape(3,3,2).swapaxes(0,2) # a: array([[ 0, 1], [ 2, 3], [ 4, 5], [ 6, 7], [ 8, 9], [10, 11], [12, 13], [14, 15], [16, 17]]) # b: array([[[ 0, 6, 12], [ 2, 8, 14], [ 4, 10, 16]], [[ 1, 7, 13], [ 3, 9, 15], [ 5, … Read more