python | num py . ndaarray . _ _ ne ()

哎哎哎:# t0]https://www . geeksforgeeks . org/python-num py-num py-ndaarray- _ ne _/

借助 Numpynumpy.ndarray.ne() 方法,我们可以发现数组中的哪个元素是不等于参数中提供的值。它将返回一个布尔类型的 numpy 数组,只有值

语法:n 数组。 _ ne _ ($自我,价值,/)

回归:自我!=值

示例#1 : 在这个示例中,我们可以看到在应用numpy.__ne__()之后,我们得到了简单的布尔数组,它可以告诉我们数组中的哪个元素不等于提供的参数的元素。

# import the important module in python
import numpy as np

# make an array with numpy
gfg = np.array([1, 2, 3, 4, 5, 6])

# applying numpy.__ne__() method
print(gfg.__ne__(4))

Output:

[ True  True  True False  True  True]

例 2 :

# import the important module in python
import numpy as np

# make an array with numpy
gfg = np.array([[1, 2, 3, 4, 5, 6],
                [6, 5, 4, 3, 2, 1]])

# applying numpy.__ne__() method
print(gfg.__ne__(4))

Output:

[[ True  True  True False  True  True]
 [ True  True False  True  True  True]]