numpy.transpose
- numpy.transpose(a, axes=None)
Returns an array with axes transposed.
For a 1-D array, this returns an unchanged view of the original array, as a transposed vector is simply the same vector. To convert a 1-D array into a 2-D column vector, an additional dimension must be added, e.g.,
np.atleast_2d(a).Tachieves this, as doesa[:, np.newaxis]. For a 2-D array, this is the standard matrix transpose. For an n-D array, if axes are given, their order indicates how the axes are permuted (see Examples). If axes are not provided, thentranspose(a).shape == a.shape[::-1].