i have this two numpy arrays
arr1 = np.empty( (3,) , dtype=np.object)
arr1[0] = [1,2]
arr1[1] = [1,2,3]
arr1[2] = None
arr2 = np.empty( (3,) , dtype=np.object)
arr2[0] = np.array([1,2])
arr2[1] = np.array([1,2,3])
arr2[2] = None
why , when i'm checking if the internal array/list is None i'm getting different results both have the same shape
In [28]: arr1 != None
Out[28]: array([ True, True, False])
In [27]: arr2 != None
Out[27]: True
what is the way in numpy to check, that each element in arr2 is None?
object,np.objectis justobject==on annp.ndarraywill throw an error.objectdtype array is just a less performantlist[a is not None for a in arr2]. Your arrays containNonein addition to lists and arrays. Expecting the same behavior for different classes of objects is unrealistic in python. Also most operations on object dtype arrays occur at list-comprehension speeds; so don't jump through hoops trying to use them.