Python | Numpy matrix.swapaxes()
With the help of matrix.swapaxes()
method, we are able to swap the axes a matrix by using the same method.
Syntax : matrix.swapaxes()
Return : Return matrix having interchanged axes
Example #1 :
In this example we are able to swap the axes of a matrix by using matrix.swapaxes()
method.
import numpy as np
gfg = np.matrix( '[4, 1; 12, 3]' )
geek = gfg.swapaxes( 0 , 1 )
print (geek)
|
Example #2 :
import numpy as np
gfg = np.matrix( '[4, 1, 9; 12, 3, 1; 4, 5, 6]' )
geek = gfg.swapaxes( 1 , 1 )
print (geek)
|
Output:
[[ 4 1 9]
[12 3 1]
[ 4 5 6]]
Last Updated :
20 May, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...