numpy.flatiter
- 
class numpy.flatiter[source]
- 
Flat iterator object to iterate over arrays. A flatiteriterator is returned byx.flatfor any arrayx. It allows iterating over the array as if it were a 1-D array, either in a for-loop or by calling itsnextmethod.Iteration is done in row-major, C-style order (the last index varying the fastest). The iterator can also be indexed using basic slicing or advanced indexing. See also - 
 ndarray.flat
- Return a flat iterator over an array.
- 
 ndarray.flatten
- Returns a flattened copy of an array.
 NotesA flatiteriterator can not be constructed directly from Python code by calling theflatiterconstructor.Examples>>> x = np.arange(6).reshape(2, 3) >>> fl = x.flat >>> type(fl) <type 'numpy.flatiter'> >>> for item in fl: ... print(item) ... 0 1 2 3 4 5 >>> fl[2:4] array([2, 3]) Attributes: - base
- 
A reference to the array that is iterated over. >>> x = np.arange(5) >>> fl = x.flat >>> fl.base is x True 
- 
 coords
- 
An N-dimensional tuple of current coordinates. 
- index
- 
Current flat index into the array. >>> x = np.arange(6).reshape(2, 3) >>> fl = x.flat >>> fl.index 0 >>> fl.next() 0 >>> fl.index 1 
 Methodscopy()Get a copy of the iterator as a 1-D array. 
- 
 
    © 2005–2019 NumPy Developers
Licensed under the 3-clause BSD License.
    https://docs.scipy.org/doc/numpy-1.16.1/reference/generated/numpy.flatiter.html