numpy.equal with string values
Posted
by Morgoth
on Stack Overflow
See other posts from Stack Overflow
or by Morgoth
Published on 2010-03-14T16:22:44Z
Indexed on
2010/03/14
16:25 UTC
Read the original article
Hit count: 286
The numpy.equal function does not work if a list or array contains strings:
>>> import numpy
>>> index = numpy.equal([1,2,'a'],None)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: function not supported for these types, and can't coerce safely to supported types
What is the easiest way to workaround this without looping through each element? In the end, I need index
to contain a boolean array indicating which elements are None
.
© Stack Overflow or respective owner