array([ ] ][ ]]out[ ]array([ ] ] ] ] ]]when doing matrix computationsyou will do this very oftenlike for example computing the inner matrix product xtx using np dotin [ ]arr np random randn( in [ ]np dot(arr tarrout[ ]array([ ] ] ]]for higher dimensional arraystranspose will accept tuple of axis numbers to permute the axes (for extra mind bending)in [ ]arr np arange( reshape(( )in [ ]arr out[ ]array([[ ] ]][ ][ ]]]in [ ]arr transpose(( )out[ ]array([[ ] ]][ ][ ]]]simple transposing with is just special case of swapping axes ndarray has the method swapaxes which takes pair of axis numbersin [ ]arr out[ ]array([[ ] ]][ ][ ]]]in [ ]arr swapaxes( out[ ]array([[ ] ] ] ]][ ] ][ ][ ]]]swapaxes similarly returns view on the data without making copy numpy basicsarrays and vectorized computation www it-ebooks info