Numpy: Iterating Arrays Using nditer()

In Numpy, there is a package numpy.nditer to iterate each element of Numpy array. It is a multi-dimensional iterator. Basically, It can be used from basic to advanced iterations. It also solves some basic issues.

Example:

import numpy as np
array_0 = np.array([[['a','b','c'], ['d','e','f']],[[1,2,3],[4,5,6]]])
for x in np.nditer(array_0):
    print(x)

Output:

a
b
c
d
e
f
1
2
3
4
5
6
Wed, 09/01/2021 - 15:15

Authored by

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.