Python Numpy MaskedArray.__ior__()
numpy.ma.MaskedArray类是ndarray的一个子类,旨在处理有缺失数据的数字数组。在Numpy MaskedArray.__ior__
的帮助下,我们可以通过MaskedArray.__ior__()
方法中提供的参数获得OR的元素。
语法: numpy.MaskedArray.__ior__($self, value, /)
返回:返回self|=value。
例子#1 :
在这个例子中,我们可以看到,每个元素都是由MaskedArray.__ior__()
方法中作为参数传递的值来OR。
# 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]]