NumPy Array manipulation: transpose() function

In Python Numpy transpose() function is used to perform transpose. It can transpose 2-D array.  In mathematics matrix transpose is used to convert rows into column and vice-versa.Therefore in Numpy array transposing simply convert rows into columns and columns into rows.

Syntax

numpy.transpose(a, axes=None)

Example

import numpy as np
A= np.array([[1,2,3],
                [4,5,6],
                [7,8,9]])
  
print(A.transpose())#After Transpose

Output:

[[1 4 7]
 [2 5 8]
 [3 6 9]]