In this example we will show how to change the datatype of elements while iterating through the NumPy array in Python.
Source Code
import numpy as np
n = np.array([1, 2, 3, 4, 5])
for i in np.nditer(n, flags=['buffered'], op_dtypes=['S']):
print(i)
Output:
b'1'
b'2'
b'3'
b'4'
b'5'