nanequal#

nanequal(arr, *args, scalar=False, equal_nan=True)[source]#

Compare two or more arrays for equality element-wise, treating NaN values as equal.

Unnlike numpy.array_equal(), this function works even if the arrays cannot be cast to float.

Parameters:
  • arr (array) – the array to use as the base for the comparison

  • args (list) – one or more arrays to compare to

  • scalar (bool) – whether to return a true/false value (else return the array)

Examples:

arr1 = np.array([1, 2, np.nan])
arr2 = [1, 2, np.nan]
sc.nanequal(arr1, arr2) # Returns array([ True,  True,  True])

arr3 = [3, np.nan, 'foo']
sc.nanequal(arr3, arr3, arr3, scalar=True) # Returns True

New in version 3.1.0.