Skip to content Skip to sidebar Skip to footer

Numpy: Creating A Vector Through Array Comparison Is NOT Working

As shown in the IPython (Python 3) snapshot below I expect to see an array of Boolean values printed in the end. However, I see ONLY 1 Boolean value returned. Unable to identify w

Solution 1:

Python has the distinction between unicode strings and ASCII bytes. In Python3, the default is that "strings" are unicode.

The b prefixing the "strings", indicate that the interpreter considers these to be bytes.

For the comparison, you need to compare it to bytes as well, i.e.,

... == b"1984"

and then numpy will understand that it should perform broadcasting on same-type elements.


Post a Comment for "Numpy: Creating A Vector Through Array Comparison Is NOT Working"