鉴于:
import numpy as np
a = np.arange(6)
b = np.arange(24).reshape(6,4)
我想要这样的东西:
for i in xrange(len(a)):
v1 = a[i]
v2 = b[i,...]
但我不知道如何使用nditer?
it = np.nditer((a,b))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-4-7fe57c985cae> in <module>()
----> 1 it = np.nditer((a,b))
ValueError: operands could not be broadcast together with shapes (6) (6,4)
这适用于单个操作数,但我该如何处理不同等级的操作数?
a = np.arange(6).reshape(2,3)
for x in np.nditer(a, flags=['external_loop'], order='F'):
... print x,