当前位置: 首页>>编程示例 >>用法及示例精选 >>正文


Python Numpy MaskedArray.__ior__()用法及代码示例

numpy.ma.MaskedArray class是ndarray的子​​类,旨在处理缺少数据的数字数组。借助于Numpy MaskedArray .__ ior__,我们可以通过MaskedArray.__ior__()方法中作为参数提供的值来获得OR元素。

用法: numpy.MaskedArray.__ior__($self, value, /)

返回:返回self | = value。


范例1:
在此示例中,我们可以看到每个元素都是MaskedArray.__ior__()方法中作为参数传递的值的或。

# import the important module in python  
import numpy as np  
      
# make an array with numpy  
gfg = np.ma.array([1, 2, 3, 4, 5])  
      
# applying MaskedArray.__ior__() method  
print(gfg.__ior__(2))  
  
输出:
[3 2 3 6 7]


范例2:

# import the important module in python  
import numpy as np  
      
# make an array with numpy  
gfg = np.ma.array([[1, 2, 3, 4, 5],  
                [6, 5, 4, 3, 2]])  
      
# applying MaskedArray.__ior__() method  
print(gfg.__ior__(1)) 
输出:
[[1 3 3 5 5]
 [7 5 5 3 3]]


相关用法


注:本文由纯净天空筛选整理自Shivam_k大神的英文原创作品 Python | Numpy MaskedArray.__ior__()。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。