numpy.core.defchararray.not_equal(arr1, arr2)
是另一个在numpy中执行字符串操作的函数。它一一检查两个相同形状数组的元素,如果不相等,则返回True。否则,它返回False。
参数:
arr1 :str或unicode的数组。
arr2 :str或unicode的数组。
返回:[ndarray] bool的输出数组;如果arr1和arr2是标量,则为单个bool。
代码1:
# Python program explaining
# numpy.char.not_equal() method
# importing numpy
import numpy as geek
# input arrays
in_arr1 = geek.array('numpy')
print ("1st Input array:", in_arr1)
in_arr2 = geek.array('nump')
print ("2nd Input array:", in_arr2)
# checking if they are not equal
out_arr = geek.char.not_equal(in_arr1, in_arr2)
print ("Output array:", out_arr)
输出:
1st Input array: numpy 2nd Input array: nump Output array: True
代码2:
# Python program explaining
# numpy.char.not_equal() method
# importing numpy
import numpy as geek
# input arrays
in_arr1 = geek.array(['Geeks', 'for', 'Geeks'])
print ("1st Input array:", in_arr1)
in_arr2 = geek.array(['Geek', 'for', 'Geek'])
print ("2nd Input array:", in_arr2)
# checking if they are not equal
out_arr = geek.char.not_equal(in_arr1, in_arr2)
print ("Output array:", out_arr)
输出:
1st Input array: ['Geeks' 'for' 'Geeks'] 2nd Input array: ['Geek' 'for' 'Geek'] Output array: [ True False True]
代码3:
# Python program explaining
# numpy.char.not_equal() method
# importing numpy
import numpy as geek
# input arrays
in_arr1 = geek.array(['10', '11', '12'])
print ("1st Input array:", in_arr1)
in_arr2 = geek.array(['10', '11', '121'])
print ("2nd Input array:", in_arr2)
# checking if they are not equal
out_arr = geek.char.not_equal(in_arr1, in_arr2)
print ("Output array:", out_arr)
输出:
1st Input array: ['10' '11' '12'] 2nd Input array: ['10' '11' '121'] Output array: [False False True]
相关用法
- Numpy string less()用法及代码示例
- Numpy string index()用法及代码示例
- Numpy string title()用法及代码示例
- Numpy string join()用法及代码示例
- Numpy string find()用法及代码示例
- Numpy string lstrip()用法及代码示例
- Numpy string strip()用法及代码示例
- Numpy string isspace()用法及代码示例
- Numpy string swapcase()用法及代码示例
- Numpy string rjust()用法及代码示例
- Numpy string rstrip()用法及代码示例
- Numpy string ljust()用法及代码示例
- Numpy string count()用法及代码示例
- Numpy string split()用法及代码示例
- Numpy string translate()用法及代码示例
注:本文由纯净天空筛选整理自jana_sayantan大神的英文原创作品 numpy string operations | not_equal() function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。