Python| Numpy MaskedArray.__itruediv__
numpy.ma.MaskedArray class
是 ndarray 的子类,旨在处理缺失数据的数值数组。在 Numpy MaskedArray.__itruediv__的帮助下,我们可以在 MaskedArray.__itruediv__() 方法中获取作为参数提供的特定值。
Syntax: numpy.MaskedArray.__itruediv__(other)
Return: True divide self by other in-place.
示例 #1:
在这个例子中,我们可以看到数组中的每个元素都被作为 MaskedArray.__itruediv__() 方法中的参数给出的值划分。
# import the important module in python
import numpy as np
# make an array with numpy
gfg = np.ma.array([1, 2.5, 3, 4.8, 5])
# applying MaskedArray.__itruediv__() method
print(gfg.__itruediv__(2))
输出:
[ 0.5 1.25 1.5 2.4 2.5 ]
示例 #2:
# import the important module in python
import numpy as np
# make an array with numpy
gfg = np.ma.array([[1, 2, 3, 4.45, 5],
[6, 5.5, 4, 3, 2.62]])
# applying MaskedArray.__itruediv__() method
print(gfg.__itruediv__(5))
输出:
[[ 0.2 0.4 0.6 0.89 1. ]
[ 1.2 1.1 0.8 0.6 0.524]]