numpy.ndenumerate#

classnumpy.ndenumerate(arr)[source]#

Multidimensional index iterator.

Return an iterator yielding pairs of array coordinates and values.

Parameters:
arrndarray

Input array.

Examples

>>>importnumpyasnp>>>a=np.array([[1,2],[3,4]])>>>forindex,xinnp.ndenumerate(a):...print(index,x)(0, 0) 1(0, 1) 2(1, 0) 3(1, 1) 4
On this page