[Numpy-discussion] Transpose Array How?
Wed Jun 23 15:26:57 CDT 2010
Angus McMorland wrote:
> On 23 June 2010 16:13, Alan Bromborsky <email@example.com> wrote:
>> Alan Bromborsky wrote:
>>> In the transpose function we have transpose(a,axis) where axis can be a
>>> list of integers. But exactly what to the integers mean? If axis =
>>> [i1,i2] switching axis i1 with axis i2 is obvious, but what if axis =
>>> [i1,i2,i3]. Does this describe a cyclic permutation where
>>> i1->i2->i3->i2 or what does it describe?
> The integers represent previous dimension positions, and the position
> of the integers in the transpose argument represent the new positions.
>>>> a = np.ones((5,6,7))
> (5, 6, 7)
>>>> np.transpose(a, (1,0,2)).shape
> (6, 5, 7)
> i.e. the dimension 1 in a is moved to the 0th position, dimension 0 in
> a is in the 1th position, and dimension 2 stays the same.
Thank you. That is what I needed to know.
More information about the NumPy-Discussion