借助Numpy matrix.getfield()方法,我们可以获得字段矩阵,这意味着field是具有给定数据类型的矩阵的视图,该数据类型的大小与给定矩阵的大小相同。
用法: matrix.getfield()
返回: 返回场矩阵
范例1:
在此示例中,我们可以看到可以借助方法获得字段矩阵matrix.getfield()。
# import the important module in python 
import numpy as np 
          
# make matrix with numpy 
gfg = np.matrix('[6, 1; 2, 3]') 
          
# applying matrix.getfield() method 
geeks = gfg.getfield(int) 
    
print(geeks)
输出:
[[6 1] [2 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.getfield() method 
geeks = gfg.getfield(int) 
    
print(geeks)
输出:
[[1 2 3] [4 5 6] [7 8 9]]
相关用法
- Python Numpy numpy.ndarray.__mod__()用法及代码示例
 - Python Numpy numpy.ndarray.__ge__()用法及代码示例
 - Python Numpy numpy.ndarray.__invert__()用法及代码示例
 - Python Numpy numpy.ndarray.__divmod__()用法及代码示例
 - Python Numpy numpy.ndarray.__eq__()用法及代码示例
 - Python Numpy numpy.ndarray.__pow__()用法及代码示例
 - Python Numpy numpy.ndarray.__rshift__()用法及代码示例
 - Python Numpy numpy.ndarray.__le__()用法及代码示例
 - Python Numpy numpy.ndarray.__lt__()用法及代码示例
 - Python Numpy numpy.ndarray.__gt__()用法及代码示例
 - Python Numpy numpy.ndarray.__truediv__()用法及代码示例
 - Python Numpy numpy.ndarray.__mul__()用法及代码示例
 - Python Numpy numpy.ndarray.__sub__()用法及代码示例
 - Python Numpy numpy.ndarray.__pos__()用法及代码示例
 - Python Numpy numpy.ndarray.__add__()用法及代码示例
 
注:本文由纯净天空筛选整理自Jitender_1998大神的英文原创作品 Python | Numpy matrix.getfield()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
