I have an array which looks like:
array([[ 1., 2., None],
[ nan, 4., 5.]])
I am trying the following:
np.equal(A, None) #works and finds index of None correctly
np.equal(A, np.nan) #doesn't work
np.isnan(A) #errors out
The error is:
TypeError: ufunc 'isnan' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''
How should I approach this, I am trying to find the index of None and nan in a given array.
My final output should look as:
array([[False, False, True],
[True, False, False]], dtype=bool)
np.nanis a proper float, butNoneis an object. So your array has dtype object.