How to understand numpy's combined slicing and indexing example
<p>I am trying to understand numpy's combined slicing and indexing concept, however I am not sure how to correctly get the below results from numpy's output (by hand so that we can understand how numpy process combined slicing and indexing, which one will be process first?):</p>

<pre><code>&gt;&gt;&gt; import numpy as np
&gt;&gt;&gt; a=np.arange(12).reshape(3,4)
&gt;&gt;&gt; a
array([[ 0,  1,  2,  3],
       [ 4,  5,  6,  7],
       [ 8,  9, 10, 11]])
&gt;&gt;&gt; i=np.array([[0,1],[2,2]])
&gt;&gt;&gt; a[i,:]
array([[[ 0,  1,  2,  3],
        [ 4,  5,  6,  7]],

       [[ 8,  9, 10, 11],
        [ 8,  9, 10, 11]]])
&gt;&gt;&gt; j=np.array([[2,1],[3,3]])
&gt;&gt;&gt; a[:,j]
array([[[ 2,  1],
        [ 3,  3]],

       [[ 6,  5],
        [ 7,  7]],

       [[10,  9],
        [11, 11]]])
&gt;&gt;&gt; aj=a[:,j]
&gt;&gt;&gt; aj.shape
(3L, 2L, 2L)
</code></pre>

<p>I am bit confused about how aj's shape becomes (3,2,2) with the above output, any detailed explanations are very appreciated, thanks!</p>

<p><code>a[:,j][0]</code> is equivalent to <code>a[0,j]</code> or <code>[0, 1, 2, 3][j]</code> which gives you <code>[[2, 1], [3, 3]])</code></p>

<p><code>a[:,j][1]</code> is equivalent to <code>a[1,j]</code> or <code>[4, 5, 6, 7][j]</code> which gives you <code>[[6, 5], [7, 7]])</code></p>

<p><code>a[:,j][2]</code> is equivalent to <code>a[2,j]</code> or <code>[8, 9, 10, 11][j]</code> which gives you <code>[[10, 9], [11, 11]])</code></p>

python arrays numpy indexing