Python | Numpy ndarray.T

Using the Numpy ndarray.T object, we can Transpose for an array that is greater than or equal to 2.

Syntax: ndarray.T

Return: Transpose of an array

Example # 1:
In this example, we see that using the ndarray.T object we can transform an array.

# import important module in python

import numpy as np

 
# make an array with NumPy

gfg = np.array ([[ 1 , 2 , 3 ], [ 4 , 5 , 6 ]])

 
# applying the ndarray object .T

geeks = gfg.T

 

print (geeks)

Exit:

 [[1 4] [2 5] [3 6]] 

Example # 2:

# import an important module into python

import numpy as np

  
# make an array with NumPy

gfg = np.array ([[ 1 , 2 , 3 , 4 ], [ 4 , 5 , 6 , 7 ], [ 7 , 8 , 9 , 0 ]])

 
# applying the ndarray.T object

geeks = gfg.T

 

print (geeks)

Exit:

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