【发布时间】:2013-08-19 18:38:37
【问题描述】:
当使用numpy.ndenumerate 时,索引按照C-contiguous 数组顺序返回,例如:
import numpy as np
a = np.array([[11, 12],
[21, 22],
[31, 32]])
for (i,j),v in np.ndenumerate(a):
print i, j, v
如果a 中的order 是'F' 或'C',则不行,这给出:
0 0 11
0 1 12
1 0 21
1 1 22
2 0 31
2 1 32
numpy 中是否有任何内置迭代器,例如 ndenumerate 来给出这个(在数组 order='F' 之后):
0 0 11
1 0 21
2 0 31
0 1 12
1 1 22
2 1 32
【问题讨论】:
标签: python arrays numpy iterator iteration