Python| Numpy MaskedArray.__ifloordiv__
numpy.ma.MaskedArray class
是 ndarray 的子类,旨在处理缺失数据的数值数组。在 Numpy MaskedArray.__ifloordiv__的帮助下,我们可以获得作为 MaskedArray.__ifloordiv__() 方法中的参数提供的特定值的楼层划分。
Syntax: numpy.MaskedArray.__ifloordiv__(other)
Return: Floor divide self by other in-place.
示例 #1:
在这个例子中,我们可以看到数组中的每个元素都被作为 MaskedArray.__ifloordiv__() 方法中的参数给出的值划分。
# import the important module in python
import numpy as np
# make an array with numpy
gfg = np.ma.array([10, 20.5, 30, 4.8, 50])
# applying MaskedArray.__ifloordiv__() method
print(gfg.__ifloordiv__(2))
输出:
[ 5. 10. 15. 2. 25.]
示例 #2:
# import the important module in python
import numpy as np
# make an array with numpy
gfg = np.ma.array([[10, 20, 30, 4.45, 50],
[6, 5.5, 4, 3, 2.62]])
# applying MaskedArray.__ifloordiv__() method
print(gfg.__ifloordiv__(5))
输出:
[[ 2. 4. 6. 0. 10.]
[ 1. 1. 0. 0. 0.]]