NumPy | transpose method
transpose(~) method flips the rows and columns, just as in the context of matrices.
The input array.
The axis along which to perform the transpose. By default, flips the columns and rows for 2D arrays.
a is a scalar, then a scalar is returned. Otherwise, a Numpy array is returned.
Consider the following 2D array:
a = np.array([[4,5],[6,7]])aarray([[4, 5],[6, 7]])
Taking the transpose gives:
np.transpose(a)array([[4, 6],[5, 7]])
Notice how the rows and columns flipped.