Python| Numpy MaskedArray.__rlshift__
numpy.ma.MaskedArray class
是 ndarray 的子类,旨在处理缺失数据的数值数组。在 Numpy MaskedArray.__rlshift__方法的帮助下,我们可以获得按作为参数提供的值右移的元素。
Syntax: numpy.MaskedArray.__rlshift__
Return: Return value<
示例 #1:
在这个例子中,我们可以看到每个元素都右移了作为参数传递的值。
# 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.__rlshift__() method
print(gfg.__rlshift__(2))
输出:
[ 4 8 16 32 64]
示例 #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.__rlshift__() method
print(gfg.__rlshift__(1))
输出:
[[ 2 4 8 16 32]
[64 32 16 8 4]]