Python Numpy MaskedArray.__rxor__

numpy.ma.MaskedArray类是ndarray的一个子类,旨在处理有缺失数据的数字数组。在Numpy MaskedArray.__rxor__方法的帮助下,我们可以得到与作为参数提供的值进行的元素。

语法: numpy.MaskedArray.__rxor__($self, value, /)

返回:返回值^self。

例子#1 :
在这个例子中,我们可以看到,每个元素都与作为参数传递的值进行了xor。

   
# 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.__rxor__() method 
print(gfg.__rxor__(2)) 

输出:

[3 0 1 6 7]

示例 #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.__rxor__() method 
print(gfg.__rxor__(1)) 

输出:

[[0 3 2 5 4]
 [7 4 5 2 3]]

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程