import numpy as np
an=np.array([[1,2,3,4],[5,6,7,8],[9,10,11,12]])
bn=np.empty(shape=(an.shape[1],an.shape[0]))
for i in range(an.shape[0]):
for j in range(an.shape[1]):
bn[j,an.shape[0]-1-i]=an[i,j]
Было:
array([[ 1, 2, 3, 4],
[ 5, 6, 7, 8],
[ 9, 10, 11, 12]])
Результат:
array([[ 9., 5., 1.],
[10., 6., 2.],
[11., 7., 3.],
[12., 8., 4.]])
Или на "голых" списках:
n=3
m=4
a=[[1,2,3,4],[5,6,7,8],[9,10,11,12]]
k=[[0,0,0],[0,0,0],[0,0,0],[0,0,0]]
for i in range(n):
for j in range(m):
k[j][n-1-i]=a[i][j]
Результат:
[[9, 5, 1],
[10, 6, 2],
[11, 7, 3],
[12, 8, 4]]