title: Swapping the dimensions of a numpy array
body: <p>I would like to do the following:</p>
  
  <pre><code>for i in dimension1:
    for j in dimension2:
      for k in dimension3:
        for l in dimension4:
          B[k,l,i,j] = A[i,j,k,l]
  </code></pre>
  
  <p>without the use of loops. In the end both A and B contain the same information but indexed
  differently. </p>
  
  <p>I must point out that the dimension 1,2,3 and 4 can be the same or different. So a numpy.reshape() seems difficult. </p>