Python:ndarray.flatten ('F' 是否有反函数)?

标签 python arrays numpy

例如:

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/

相关文章:

java - 如何将不同的值传递给 ExecutorService 中的每个线程?

python - 在 2d numpy 数组列上计算成对 t 检验

python - 二维数组中每个元素沿第一个维度的索引数组(numpy.、tensorflow)

python - 如何找到拟合指数函数的 x ?

javascript - 在最少的运行中有效地查找并返回多个值的数组位置

python - 如何按日期绘制分组数据框

java - hasPrevious() 方法不起作用

python - 在python中打开二进制数据

python - 无法安装 Kivy python 程序

Python pandas 标记将一个数据帧中的列中的值与另一个数据帧中的列进行匹配