October 2019
Beginner to intermediate
674 pages
16h 43m
English
The transpose function reverses the dimensions of an array:
In [80]: trans_array = np.arange(0,24).reshape(4, 6)In [82]: trans_arrayOut[82]:array([[ 0, 1, 2, 3, 4, 5],[ 6, 7, 8, 9, 10, 11],[12, 13, 14, 15, 16, 17],[18, 19, 20, 21, 22, 23]])In [83]: trans_array.TOut[83]:array([[ 0, 6, 12, 18],[ 1, 7, 13, 19],[ 2, 8, 14, 20],[ 3, 9, 15, 21],[ 4, 10, 16, 22],[ 5, 11, 17, 23]])
The following result is obtained on applying transpose on a multidimensional array:
In [84]: trans_array = np.arange(0,24).reshape(2, 3, 4)In [85]: trans_array.T.shapeOut[85]: (4, 3, 2)
Read now
Unlock full access