[Numpy-discussion] Converting char array to float
Wed Nov 28 12:21:29 CST 2007
I'm trying to convert a character array to a floating point array. I'm
using one of the recent svn builds. It is surprising that astype does
not do the job. However if I first convert the char array to an array
and then use astype everything works fine. Is this a bug?
import numpy as N
print N.__version__ # Output = '1.0.5.dev4426'
a = N.char.array(['123.45', '234.56'])
b = N.array(a).astype(N.float) # This works.
b = a.astype(N.float) # This does not work and raises an exception
ValueError: Can only create a chararray from string data.
More information about the Numpy-discussion