[Numpy-discussion] rollaxis

A. M. Archibald peridot.faceted at gmail.com
Wed Dec 13 14:29:03 CST 2006


On 13/12/06, Pierre GM <pgmdevlist at gmail.com> wrote:
> All,
> I have a ND array whose axes I want to reorganize, so that axis "i" is at the
> end while the others stay in their relative position. What's the easiest ?

Generate an axis-permutation tuple and use transpose:

s = list(A.shape)
s.remove(i)
s.append(i)
B = A.transpose(s)

A. M. Archibald


More information about the Numpy-discussion mailing list