title: Iterating over 2d arrays contained in 3d array in Python
body: <p>I have seen a lot of questions asking for a faster way to iterate over each element of a 2d array, but I haven't found a good method to iterate over a 3d array in order to apply a function on each 2d array. For example:</p>
  
  <pre><code>from scipy.fftpack import dct
  X = np.arange(10000, dtype=np.float32).reshape(-1,4,4)
  np.array(map(dct, X))
  </code></pre>
  
  <p>Here I'm going through each 2d array contained in a 3d array of dimensions <code>(625,4,4)</code> and applying a DCT (discrete cosine transform) to each <code>4X4</code> array. I was wondering if there is a more suitable method to accomplish this.</p>
  
  <p>Thanks</p>