title: How can I vectorize the averaging of 2x2 sub-arrays of numpy array?
body: <p>I have a very a very large 2D numpy array that contains 2x2 subsets that I need to take the average of.  I am looking for a way to vectorize this operation.  For example, given x: </p>
  
  <pre><code>#               |- col 0 -|   |- col 1 -|   |- col 2 -|       
  x = np.array( [[ 0.0,   1.0,   2.0,   3.0,   4.0,   5.0],  # row 0
                 [ 6.0,   7.0,   8.0,   9.0,  10.0,  11.0],  # row 0
                 [12.0,  13.0,  14.0,  15.0,  16.0,  17.0],  # row 1
                 [18.0,  19.0,  20.0,  21.0,  22.0,  23.0]]) # row 1
  </code></pre>
  
  <p>I need to end up with a 2x3 array which are the averages of each 2x2 sub array, i.e.:</p>
  
  <pre><code>result = np.array( [[ 3.5,  5.5,  7.5],
                      [15.5, 17.5, 19.5]])
  </code></pre>
  
  <p>so element [0,0] is calculated as the average of x[0:2,0:2], while element [0,1] would be the average of x[2:4, 0:2].  Does numpy have vectorized/efficient ways of doing aggregates on subsets like this?</p>