First of all, in numpy structured arrays, when you specify datatype as str numpy assumes it to be a 1 character string.
>>> a = numpy.zeros((10, 10), dtype=[
("x", int),
("y", str)])
>>> print a.dtype
dtype([('x', '<i8'), ('y', 'S')])
As a result the values you enter get truncated to 1 character.
>>> a["y"][0][0] = "hello"
>>> print a["y"][0][0]
h
Hence use data type as a10, Where 10 being the max length of your string.
Refer this link, which specifies more definitions for other data structures.
Secondly your approach seems correct to me.
Inititating a structured numpy array with datatype int and a10
>>> a = numpy.zeros((10, 10), dtype=[("x", int), ("y", 'a10')])
Filling it with random numbers
>>> a["x"][:] = numpy.random.randint(-10, 10, (10,10))
>>> print a["x"]
[[ 2 -4 -10 -3 -4 4 3 -8 -10 2]
[ 5 -9 -4 -1 9 -10 3 0 -8 2]
[ 5 -4 -10 -10 -1 -8 -1 0 8 -4]
[ -7 -3 -2 4 6 6 -8 3 -8 8]
[ 1 2 2 -6 2 -9 3 6 6 -6]
[ -6 2 -8 -8 4 5 8 7 -5 -3]
[ -5 -1 -1 9 5 -7 2 -2 -9 3]
[ 3 -10 7 -8 -4 -2 -4 8 5 0]
[ 5 6 5 8 -8 5 -10 -6 -2 1]
[ 9 4 -8 6 2 4 -10 -1 9 -6]]
Applying your filtering
>>> a["y"][a["x"]<0] = "hello"
>>> print a["y"]
[['' 'hello' 'hello' 'hello' 'hello' '' '' 'hello' 'hello' '']
['' 'hello' 'hello' 'hello' '' 'hello' '' '' 'hello' '']
['' 'hello' 'hello' 'hello' 'hello' 'hello' 'hello' '' '' 'hello']
['hello' 'hello' 'hello' '' '' '' 'hello' '' 'hello' '']
['' '' '' 'hello' '' 'hello' '' '' '' 'hello']
['hello' '' 'hello' 'hello' '' '' '' '' 'hello' 'hello']
['hello' 'hello' 'hello' '' '' 'hello' '' 'hello' 'hello' '']
['' 'hello' '' 'hello' 'hello' 'hello' 'hello' '' '' '']
['' '' '' '' 'hello' '' 'hello' 'hello' 'hello' '']
['' '' 'hello' '' '' '' 'hello' 'hello' '' 'hello']]
Verifying a["x"]
>>> print a["x"]
[[ 2 -4 -10 -3 -4 4 3 -8 -10 2]
[ 5 -9 -4 -1 9 -10 3 0 -8 2]
[ 5 -4 -10 -10 -1 -8 -1 0 8 -4]
[ -7 -3 -2 4 6 6 -8 3 -8 8]
[ 1 2 2 -6 2 -9 3 6 6 -6]
[ -6 2 -8 -8 4 5 8 7 -5 -3]
[ -5 -1 -1 9 5 -7 2 -2 -9 3]
[ 3 -10 7 -8 -4 -2 -4 8 5 0]
[ 5 6 5 8 -8 5 -10 -6 -2 1]
[ 9 4 -8 6 2 4 -10 -1 9 -6]]
print numpy.__version__)? I do not see the bleeding of characters into the integer field, but that would be a serious bug.a = numpy.zeros((10, 10), dtype=[("x", int), ("y", str)]); a["x"][:] = numpy.random.randint(-10, 10, (10, 10)); print a["x"]; a["y"][a["x"] < 0] = "hello"; print a["x"]- produces two different printed outputs.strto"a"also reproduces it.