NumPy Logic functions: array_equal() function
numpy.array_equal() function
The array_equal() function is True if two arrays have the same shape and elements, False otherwise.
Syntax:
numpy.array_equal(a1, a2)
Version: 1.15.0
Parameter:
Name | Description | Required / Optional |
---|---|---|
a1, a2 | Input arrays. array_like |
Required |
Returns:
b : bool - Returns True if the arrays are equal.
NumPy.array_equal() method Example-1:
>>> import numpy as np
>>> np.array_equal([1, 3], [1, 3])
Output:
True
NumPy.array_equal() method Example-2:
>>> import numpy as np
>>> np.array_equal(np.array([2, 4]), np.array([2, 4]))
Output:
True
NumPy.array_equal() method Example-3:
>>> import numpy as np
>>> np.array_equal([2, 4], [2, 4, 6])
Output:
False
NumPy.array_equal() method Example-4:
>>> import numpy as np
>>> np.array_equal([1, 3], [2, 5])
Output:
False
Python - NumPy Code Editor:
Previous: isclose() function
Next: array_equiv() function
It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.
https://www.w3resource.com/numpy/logic-functions/array_equal.php
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics