Python Numpy MaskedArray.__irshift__()
numpy.ma.MaskedArray类是ndarray的一个子类,旨在处理有缺失数据的数字数组。在Numpy MaskedArray.irshift的帮助下,我们可以得到被MaskedArray.irshift()方法中作为参数提供的值右移的元素。
语法: numpy.MaskedArray.__irshift__(other)
例子#1 :
在这个例子中,我们可以看到每个元素都被右移了,这个值被作为MaskedArray.irshift()方法的参数传递。
# 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.__irshift__() method
print(gfg.__irshift__(2))
输出:
[0 0 0 1 1]
示例 #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.__irshift__() method
print(gfg.__irshift__(1))
输出:
[[0 1 1 2 2]
[3 2 2 1 1]]