Transpose of an array or matrix in Python NumPy Module. The following shows how to transpose a NumPy Array of the Python NumPy module.
a = np.floor(10*np.random.random((3,4)))
a
Output:
array([[5., 9., 6., 8.],
[1., 4., 5., 4.],
[8., 0., 4., 8.]])
Code:
a.T
Output:
array([[5., 1., 8.],
[9., 4., 0.],
[6., 5., 4.],
[8., 4., 8.]])
Code:
a.T.shape
Output:
(4, 3)