Skip to main content

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
Submitted by devanshi.srivastava on September 1, 2021

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

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.