On 5/7/07, Martin Spacek <[EMAIL PROTECTED]> wrote:
I want to find the indices of all the None objects in an object array: >> import numpy as np >> i = np.array([0, 1, 2, None, 3, 4, None]) >> np.where(i == None) () Using == doesn't work the same way on object arrays as it does on, say, an array of int32. Any suggestions?
Using np.equals instead of == seems to work:
i = np.array([0,1,2,None,3,4,None]) i
array([0, 1, 2, None, 3, 4, None], dtype=object)
np.where(i == None)
()
i == None
False
np.where(np.equal(i, None))
(array([3, 6]),) I suspect the issue isn't actually object arrays, but rather some optimization related to None, that's causing problems. -tim Do I have to use a loop or list
comprehension, like this? >> [ ii for (ii, id) in enumerate(i) if id == None ] Thanks, Martin _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
-- //=][=\\ [EMAIL PROTECTED]
_______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
