赞
踩
>>> a = [[1,2,3], [4,5,6], [7, 8, 9], [10, 11, 12]]
>>> a = list(map(list, zip(*a)))
输出:
[[1, 4, 7, 10], [2, 5, 8, 11], [3, 6, 9, 12]]
>>> a = [[1,2,3], [4,5,6], [7, 8, 9], [10, 11, 12]]
>>> np.stack((a),axis=1)
输出:
array([[ 1, 4, 7, 10],
[ 2, 5, 8, 11],
[ 3, 6, 9, 12]])
>>> a = [[1,2,3], [4,5,6], [7, 8, 9], [10, 11, 12]]
>>> np.transpose(a)
array([[ 1, 4, 7, 10],
[ 2, 5, 8, 11],
[ 3, 6, 9, 12]])
>>> A = np.mat([[1,2,3],[4,5,6],[7,8,9]])
>>> A.T
>>> A.swapaxes(0, 1)
matrix([[1, 4, 7],
[2, 5, 8],
[3, 6, 9]])
>>> A = [[1,2,3],[4,5,6],[7,8,9]]
>>> B = [[A[j][i] for j in range(len(A))] for i in range(len(A[0]))]
>>> B
[[1, 4, 7], [2, 5, 8], [3, 6, 9]]
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。