I want to differentiate the None's from NaN's in a NumPy array with mixed data types. Specifically, I want to work with arrays where some elements are arrays. For example, suppose I have the following array with mixed data types, but without array elements:
arr = np.array([[1, None, 3],
[4, 5, np.nan],
[7, 'eight', 9]])
I can check what values are None with the following:
>>> arr == None
array([[False, True, False],
[False, False, False],
[False, False, False]])
This gets the result that I want: a Boolean mask with information about the individual elements, saying which elements are None. However, the snippet above doesn't work when any element in the array is another array. For example, consider this other array:
arr_elem = np.array([3,3,3])
arr = np.array([[1, None, arr_elem],
[4, 5, np.nan],
[7, 'eight', 9]])
Now, instead of a Boolean mask, I obtain a single Boolean value:
>>> arr == None
False
What is a vectorized way to obtain a Boolean mask that says which elements are None and not NaN in an array of arrays?