numpy.ndenumerate()

numpy.ndenumerate

class numpy.ndenumerate(arr) [source]

Multidimensional index iterator.

Return an iterator yielding pairs of array coordinates and values.

Parameters:

arr : ndarray

Input array.

See also

ndindex, flatiter

Examples

>>> a = np.array([[1, 2], [3, 4]])
>>> for index, x in np.ndenumerate(a):
...     print(index, x)
(0, 0) 1
(0, 1) 2
(1, 0) 3
(1, 1) 4

Methods

next() Standard iterator method, returns the index tuple and array value.

© 2008–2017 NumPy Developers
Licensed under the NumPy License.
https://docs.scipy.org/doc/numpy-1.12.0/reference/generated/numpy.ndenumerate.html

在线笔记
App下载
App下载

扫描二维码

下载编程狮App

公众号
微信公众号

编程狮公众号

意见反馈
返回顶部