例如:
from numpy import * x = array([[1,2],[3,4],[5,6]]) print x.flatten('F') >>>[1 3 5 2 4 6]
是否可以从[1 3 5 2 4 6]得到[[1,6]]?
解决方法
>>> a = numpy.array((1,3,5,2,4,6)) >>> a.reshape(2,-1).T array([[1,6]]) >>>
例如: from numpy import *x = array([[1,2], [3, 4], [5, 6]])print x.flatten(F)[1 3 5 2 4 6] 是否可以从[1 3 5 2 4 6]得到[[1,2],[3,4],[5,6]]? a = numpy.array((1, 3, 5, 2 ,4, 6)) a.reshape(2, -1).T
例如:
from numpy import * x = array([[1,2],[3,4],[5,6]]) print x.flatten('F') >>>[1 3 5 2 4 6]
是否可以从[1 3 5 2 4 6]得到[[1,6]]?
>>> a = numpy.array((1,3,5,2,4,6)) >>> a.reshape(2,-1).T array([[1,6]]) >>>