Python| Numpy MaskedArray.__rtruediv__
numpy.ma.MaskedArray class
是 ndarray 的子类,旨在处理缺失数据的数值数组。在 Numpy MaskedArray.__rtruediv__的帮助下,我们可以划分在 MaskedArray.__rtruediv__() 方法中作为参数提供的特定值。
Syntax: numpy.MaskedArray.__rtruediv__
Return: Divide self into others, and return a new masked array.
示例 #1:
在这个例子中,我们可以看到数组中的每个元素都被方法 MaskedArray.__rtruediv__() 中作为参数给出的值划分。
# 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.__rtruediv__() method
print(gfg.__rtruediv__(11))
输出:
[0.5 0.3333333333333333 0.25 0.2 0.14285714285714285]
示例 #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],
[110, 220, 330, 440, 550]])
# applying MaskedArray.__rtruediv__() method
print(gfg.__rtruediv__(10))
输出:
[[1.0 0.5 0.3333333333333333 0.25 0.2]
[0.09090909090909091 0.045454545454545456 0.030303030303030304
0.022727272727272728 0.01818181818181818]]