I am unable to iterate over the outer axis of a numpy array.
import numpy as np
a = np.arange(2*3).reshape(2,3)
it = np.nditer(a)
for i in it:
print i
and this gives, as one would expect:
0
1
2
3
4
5
I would, however, like the output to come in threes, such that I have iterated over the outer axes:
(0, 1, 2)
(3, 4, 5)
I know of many ways in which I can achieve this, but after pouring over the nditer documentation, I can't seem to find a solution using nditer. I am using this as an opportunity to learn nditer. So I would prefer not using other solutions, unless it is genuinely more efficient or pythonic.
it = np.nditer(a)line