[Numpy-discussion] Transpose Array How?
Angus McMorland
amcmorl at gmail.com
Wed Jun 23 16:22:06 EDT 2010
On 23 June 2010 16:13, Alan Bromborsky <abrombo at verizon.net> 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))
>>> a.shape
(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.
HTH,
Angus.
--
AJC McMorland
Post-doctoral research fellow
Neurobiology, University of Pittsburgh
More information about the NumPy-Discussion
mailing list