Python | Numpy numpy.matrix.T ()



Using the Numpy numpy.matrix.T () method we can transpose any matrix that has dimension one or more.

Syntax: numpy.matrix.T()

Return: Return transpose of every matrix

Example # 1:
In this example, we see that using the matrix.T () method we can transform any matrix type.

# import important module into python

import numpy as np

  
# make a matrix with NumPy

gfg = np.matrix ( `[1, 2, 3, 4]` )

 
# applying the method matrix.T ()

geeks = gfg.getT ()

 

print (geeks)

Output:

 [[1] [2] [3] [4]] 

Example # 2:

# import important module in python

import numpy as np

 
# make a matrix with NumPy

gfg = np.matrix ( `[1, 2, 3; 4, 5, 6; 7, 8, 9] ` )

  
# using the matrix.T () method

geeks = gfg.getT ()

 

print (geeks)

Exit:

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