Python| Numpy MaskedArray.__div__
numpy.ma.MaskedArray class
是 ndarray 的子类,旨在处理缺失数据的数值数组。在 Numpy MaskedArray.__div__ 的帮助下,我们可以划分在 MaskedArray.__div__() 方法中作为参数提供的特定值。
Syntax: numpy.MaskedArray.__div__
Return: Divide other into self, and return a new masked array.
示例 #1:
在这个例子中,我们可以看到数组中的每个元素都被作为 MaskedArray.__div__() 方法中的参数给出的值划分。
# import the important module in python
import numpy as np
# make an array with numpy
gfg = np.ma.array([22, 33, 44, 55, 77])
# applying MaskedArray.__div__() method
print(gfg.__div__(11))
输出:
[2.0 3.0 4.0 5.0 7.0]
示例 #2:
# import the important module in python
import numpy as np
# make an array with numpy
gfg = np.ma.array([[10, 20, 30, 40, 50],
[11, 22, 33, 44, 55]])
# applying MaskedArray.__div__() method
print(gfg.__div__(5))
输出:
[[2.0 4.0 6.0 8.0 10.0]
[2.2 4.4 6.6 8.8 11.0]]