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)
의 순서로 접근
'파이썬' 카테고리의 다른 글
Matplotlib scatter/line graph (0) | 2019.09.29 |
---|---|
Numpy 이것저것 (0) | 2019.09.29 |
클래스, Exception, with 구문 (0) | 2019.09.28 |
파이썬의 람다(Lambda) 함수 (0) | 2019.09.28 |
Python 2/3 동시 설치시 선택적으로 버전 사용법(구림 -_-) (0) | 2019.08.21 |