[Numpy-discussion] Convert array type

Gary Ruben gruben@bigpond.net...
Sat Oct 6 23:37:42 CDT 2007


Try using astype. This works:

values = array(wavearray.split()).astype(float)

Gary R.

Adam Mercer wrote:
> values = array(wavearray.split())
> 
> where wavearray is a string containing a series of floats separated by
> white space, it appears that the individual elements of the values
> array are strings, where I need them to be floats.  How can I ensure
> that the individual elements of the values array are floats, not
> strings?
> 
> I have tried using
> 
> values = array(wavearray.split(), dtype=float)


More information about the Numpy-discussion mailing list