I have a question about comparing equality with numpy and string arrays. Let's say I define the following array:
x = np.array(['yes', 'no', 'maybe'])
Then I can check for equality with other lines, and it does an elementary comparison with one line (the following, I think, broadcast rules are here: http://docs.scipy.org/doc/numpy-1.10.1/user/basics. broadcasting.html ?):
'yes' == x
However, if I compare strings with unicode, I get different behavior using elementary comparison only if I compare an array with a string, and only one comparison is performed if I compare a string with an array.
x == u'yes'
I cannot find details about this behavior in numpy docs and was hoping someone could explain or point out details to me why the comparison with unicode strings behaves differently?
source share