What confuses me is the behavior of type conversion when building a structured / re-expression:
This simple example accepts numeric fields, but defines the type as a string:
data = [(1.0, 2), (3.0, 4)] np.array(data, dtype=[('x', str), ('y', int)])
What produces:
array([('', 2), ('', 4)], dtype=[('x', 'S'), ('y', '<i8')])
Thus, the values ββwere converted to empty strings, which you do not expect from:
str(1.0)
Creates the string '1.0' . What causes this behavior?
source share