Hi Everyone,

Is Numpy supposed to behave this like this when converting an array of
numbers to an array of strings with astype?

print(arange(20).astype(np.str))
['0' '1' '2' '3' '4' '5' '6' '7' '8' '9' '1' '1' '1' '1' '1' '1' '1'
'1' '1' '1']

When I do the following it works fine,

print(arange(20).astype('|S2'))
['0' '1' '2' '3' '4' '5' '6' '7' '8' '9' '10' '11' '12' '13' '14' '15'
'16' '17' '18' '19']

I would have thought that astype would be more intelligent with
strings rather than just resorting to the first character for each
element. Is this a bug or or is it how astype works?

Thanks,

Eli
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to