파이썬
numpy iterator
카멜레온개발자
2019. 9. 29. 17:56
모든 항목을 접근
import numpy as np
A = np.array([[10, 20, 30, 40], [50, 60, 70, 80]])
print(A, "\n")
print("A.shape == ", A.shape, "\n")
it = np.nditer(A, flags=['multi_index'], op_flags=['readwrite'])
while not it.finished:
idx = it.multi_index
print("current value => ", A[idx])
it.iternext()
* 2 x 4행렬의 경우
(0, 0) -> (0, 1) -> (0, 2) -> (0, 3) -> (1, 0) -> (1, 1) -> (1, 2) -> (1, 3)
의 순서로 접근