Access all elements at given x, y position in 3-dimensional numpy array
<pre><code>mat_a = np.random.random((5, 5))
mat_b = np.random.random((5, 5))
mat_c = np.random.random((5, 5))
bigmat = np.stack((mat_a, mat_b, mat_c)) # this is a 3, 5, 5 array

for (x, y, z), value in np.ndenumerate(bigmat):
    print (x, y, z)
</code></pre>

<p>In the example above, how can I loop so that I iterate only across the 5 x 5 array and at each position I get 3 values i.e. loop should run 25 times and each time, I get an array with 3 values (one from each of mat_a, mat_b and mat_c)</p>

<ul>
<li>EDIT: Please note that I need to be able to access elements by position later i.e. if <code>bigmat</code> is reshaped, there should be a way to access element based on specific y, z</li>
</ul>

<p>The required result can be obtained by slicing, e.g.:</p>

<pre><code>for x in range(5):
    for y in range(5):
        print (bigmat[:,x,y])
</code></pre>

python numpy