Python| Numpy MaskedArray.__rmul__
numpy.ma.MaskedArray class
是 ndarray 的子类,旨在处理缺失数据的数值数组。在 Numpy MaskedArray.__rmul__的帮助下,我们可以乘以在 MaskedArray.__rmul__() 方法中作为参数提供的特定值。
Syntax: numpy.MaskedArray.__rmul__
Return: Multiply others by self, and return a new masked array.
示例 #1:
在此示例中,我们可以看到数组中的每个元素都与 MaskedArray.__rmul__() 方法中作为参数给出的值相乘。
# 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.__rmul__() method
print(gfg.__rmul__(3))
输出:
[ 3 6 9 12 15]
示例 #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.__rmul__() method
print(gfg.__rmul__(5))
输出:
[[ 5 10 15 20 25]
[30 25 20 15 10]]