How to Transpose a matrix in Single line in Python?

PythonServer Side ProgrammingProgramming

The NumPy package contains a very handy function transpose() to convert ndarray object into a transposed array

>>> a = np.array([[1, 2], [3, 4]])
>>> a
array([[1, 2],
       [3, 4]])
>>> a.transpose()
array([[1, 3],
       [2, 4]])
raja
Published on 06-Mar-2018 09:56:21
Advertisements