[Numpy-discussion] (no subject)

Warren Weckesser warren.weckesser at gmail.com
Fri Nov 22 16:35:23 EST 2013


On Fri, Nov 22, 2013 at 4:23 PM, Matthew Brett <matthew.brett at gmail.com>wrote:

> Hi,
>
> I'm sorry if I missed something obvious - but is there a vectorized
> way to look for None in an array?
>
> In [3]: a = np.array([1, 1])
>
> In [4]: a == object()
> Out[4]: array([False, False], dtype=bool)
>
> In [6]: a == None
> Out[6]: False
>
> (same for object arrays),
>



Looks like using a "scalar array" that holds the value None will work:

In [8]: a
Out[8]: array([[1, 2], 'foo', None], dtype=object)

In [9]: a == np.array(None)
Out[9]: array([False, False,  True], dtype=bool)

Warren



> Thanks a lot,
>
> Matthew
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20131122/443ae539/attachment.html>


More information about the NumPy-Discussion mailing list