Python| numpy matrix.getT()
借助Numpy matrix.getT()
方法,我们可以获得与给定矩阵相同大小的转置。
Syntax : matrix.getT()
Return : Return transpose of given matrix
示例 #1:
在这个例子中,我们可以看到我们能够在方法matrix.getT()
的帮助下获得转置。
# import the important module in python
import numpy as np
# make matrix with numpy
gfg = np.matrix('[6, 1; 2, 3]')
# applying matrix.getT() method
geeks = gfg.getT()
print(geeks)
输出:
[[6 2]
[1 3]]
示例 #2:
# import the important module in python
import numpy as np
# make a matrix with numpy
gfg = np.matrix('[1, 2, 3; 4, 5, 6; 7, 8, 9]')
# applying matrix.getT() method
geeks = gfg.getT()
print(geeks)
输出:
[[1 4 7]
[2 5 8]
[3 6 9]]