w3resource

NumPy Array manipulation: ndarray.T() function

numpy.ndarray.T() function

Permute the dimensions of an array except that self is returned if self.ndim < 2.

Syntax:

ndarray.T
NumPy manipulation: ndarray-t() function

Version: 1.15.0

Syntax:

ndarray.T

Example-1: numpy.ndarray.T()

>>> import numpy as np
>>> a = np.array([[2.,3.],[4.,5.]])
>>> a
array([[ 2.,  3.],
       [ 4.,  5.]])

Pictorial Presentation:

NumPy manipulation: ndarray-t() function

Example-2: numpy.ndarray.T()

>>> import numpy as np
>>> a = np.array([[2.,3.],[4.,5.]])
>>> a.T
array([[ 2.,  4.],
       [ 3.,  5.]])

Pictorial Presentation:

NumPy manipulation: ndarray-t() function

Example-3: numpy.ndarray.T()

>>> import numpy as np
>>> a = np.array([2.,3.,4.,5.])
>>> a
array([ 2.,  3.,  4.,  5.])
>>> a.T
array([ 2.,  3.,  4.,  5.])

Python - NumPy Code Editor:

Previous: swapaxes()
Next: transpose()