Share
The char.equal()
function in Python is used to check, one by one, if the elements of two arrays of the same shape are equal. It returns True
if they are equal. Otherwise, it returns False
.
char.equal(x1, x2)
The char.equal()
function takes two parameter values, x1
and x2
, which are two input arrays of the same shape.
The char.equal()
function returns an output array of bools.
import numpy as np# creating input arraysmyarray1 = np.array(["Theo", "10", "Numpy", "YES", "1", "and"])myarray2 = np.array(["Theo", "100", "numpy", "YES", "1", "and"])# printing the arraysprint(myarray1)print(myarray2)# implementing the char.equal() function on both arrays to see if they are equalprint(np.char.equal(myarray1, myarray2))
numpy
module.myarray1
and myarray2
, using the array()
function.myarray1
and myarray2
.char.equal()
function on the arrays to check if all the elements on both the arrays are equal. Then, we print the result to the console.