NumPy - ndarray.T function
The NumPy ndarray.T is an array attribute and it is used to get the transposed array.
Syntax
numpy.ndarray.T
Parameters
No parameter is required.
Return Value
Returns the transposed array.
Example: matrix transpose
In the example below, ndarray.T is used to get the transposed array.
import numpy as np Arr = np.array([[10,20,30],[40, 50, 60]]) ArrT = Arr.T #displaying the result print("Array is:") print(Arr) print() print("Transpose of Arr is:") print(ArrT)
The output of the above code will be:
Array is: [[10 20 30] [40 50 60]] Transpose of Arr is: [[10 40] [20 50] [30 60]]
❮ NumPy - Functions