[Numpy-discussion] Convert array type

Ryan May rmay@ou....
Mon Oct 8 12:43:00 CDT 2007

Gary Ruben wrote:
> Try using astype. This works:
> values = array(wavearray.split()).astype(float)

Why not use numpy.fromstring?

    fromstring(string, dtype=float, count=-1, sep='')

    Return a new 1d array initialized from the raw binary data in string.

    If count is positive, the new array will have count elements,
otherwise its
    size is determined by the size of string.  If sep is not empty then the
    string is interpreted in ASCII mode and converted to the desired
number type
    using sep as the separator between elements (extra whitespace is


Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma

More information about the Numpy-discussion mailing list