Python| Numpy MaskedArray.__floordiv__
numpy.ma.MaskedArray class
是 ndarray 的子类,旨在处理缺失数据的数值数组。在 Numpy MaskedArray.__floordiv__运算符的帮助下,我们可以划分一个作为参数提供给该函数的特定值。
Syntax: numpy.MaskedArray.__floordiv__
Return: Divide other into self, and return a new masked array.
示例 #1:
在这个例子中我们可以看到,在应用 MaskedArray.__floordiv__() 之后,我们得到了数组中每个元素的下限值。此方法适用于数组的正值、负值和浮点值。
# 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.__floordiv__() method
print(gfg.__floordiv__(2))
输出:
[0.0 1.0 1.0 2.0 2.0]
示例 #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.__floordiv__() method
print(gfg.__floordiv__(3))
输出:
[[0.0 0.0 1.0 1.0 1.0]
[2.0 1.0 1.0 1.0 0.0]]