title: How does numpy.swapaxes work?
body: <p>I created a sample array:</p>
  
  <pre><code>a = np.arange(18).reshape(9,2)
  </code></pre>
  
  <p>On printing, I get this as output:</p>
  
  <pre><code>[[ 0  1]
  [ 2  3]
  [ 4  5]
  [ 6  7]
  [ 8  9]
  [10 11]
  [12 13]
  [14 15]
  [16 17]]
  </code></pre>
  
  <p>On executing this reshaping:</p>
  
  <pre><code>b = a.reshape(2,3,3).swapaxes(0,2)
  </code></pre>
  
  <p>I get:</p>
  
  <pre><code>[[[ 0  9]
  [ 3 12]
  [ 6 15]]
  
  [[ 1 10]
  [ 4 13]
  [ 7 16]]
  
  [[ 2 11]
  [ 5 14]
  [ 8 17]]]
  </code></pre>
  
  <p>I went through this question, but it does not solve my problem.</p>
  
  <p><a href="https://stackoverflow.com/questions/14476415/reshape-an-array-in-numpy">Reshape an array in NumPy</a></p>
  
  <p>The documentation is not useful either.</p>
  
  <p><a href="https://docs.scipy.org/doc/numpy/reference/generated/numpy.swapaxes.html" rel="noreferrer">https://docs.scipy.org/doc/numpy/reference/generated/numpy.swapaxes.html</a></p>
  
  <p>I need to know how the swapping is working(which is x-axis, y-axis, z-axis). A diagrammatic explanation would be most helpful.</p>