例如:
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
array([[1, 2],
[3, 4],
[5, 6]])
>>>
关于Python:ndarray.flatten ('F' 是否有反函数)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5086789/