Skip to main content

NumPy Array manipulation: transpose() function

In Python Numpy transpose() function is used to perform transpose. It can transpose 2-D array.  In mathematics matrix transpose is used to convert rows into column and vice-versa.Therefore in Numpy array transposing simply convert rows into columns and columns into rows.

Syntax

numpy.transpose(a, axes=None)

Example

import numpy as np
A= np.array([[1,2,3],
                [4,5,6],
                [7,8,9]])
  
print(A.transpose())#After Transpose

Output:

[[1 4 7]
 [2 5 8]
 [3 6 9]]
Submitted by devanshi.srivastava on November 15, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.