[SciPy-user] change array index order

Nathan Bell wnbell@gmail....
Mon Mar 3 11:15:33 CST 2008


On Mon, Mar 3, 2008 at 10:54 AM, BK <lists@benair.net> wrote:

>  So, is there a way to tell scipy to somehow 'map' one index direction to
>  another one, like:
>         data_new[n,j,i] -> data_old[j,i,n]
>  without copying all the data?

I've never used it, but I think rollaxis() is what you want:
   data_new = rollaxis(data_old,2,0)

If that doesn't work, then use two calls to swapaxes()

http://www.scipy.org/Numpy_Example_List#rollaxis
http://www.scipy.org/Numpy_Example_List#swapaxes


-- 
Nathan Bell wnbell@gmail.com
http://graphics.cs.uiuc.edu/~wnbell/


More information about the SciPy-user mailing list