Fastest way to access middle four elements in Numpy array?
<p>Suppose I have a Numpy array, such as</p>

<pre><code>rand = np.random.randn(6, 6)
</code></pre>

<p>I need the central four values in the array, since it has axes of even length. If it had been odd, such as 5 by 5, then there would only be one central value. What is the simplest/fastest/easiest way of retrieving these four entries? I can obtain them very crudely with indices, but I'm looking for a faster way than calling a bunch of functions and performing a bunch of calculations.</p>

<p>For example, consider the following:</p>

<pre><code>array([[ 0.25659355, -0.75456113,  0.39467396,  0.50805361],
       [-0.77218172,  1.00016061, -0.70389486,  1.67632146],
       [-0.41106158, -0.63757421,  1.70390504, -0.79073362],
       [-0.2016959 ,  0.55316318, -1.55280823,  0.45740193]])
</code></pre>

<p>I want the following:</p>

<pre><code>array([[1.00016061, -0.70389486],
       [-0.63757421,  1.70390504]])
</code></pre>

<p>But not just for a 4 by 4 array - if it is even by even, I want the central four elements, as above.</p>