The behaviour of type conversion is pretty confusing when constructing a structured/recarray:
For example, the following code takes in numerical fields but defines the type as string:
data = [(1.0, 2), (3.0, 4)]
np.array(data, dtype=[('x', str), ('y', int)])
Which produces:
array([('', 2), ('', 4)], dtype=[('x', 'S'), ('y', '<i8')])
So the values were converted to empty strings which is not what you would expect from:
str(1.0)
Which produces the string '1.0'. Can anyone tell me the problem and how to solve this?