[Numpy-discussion] Convert array type

Gary Ruben gruben at bigpond.net.au
Sun Oct 7 00:37:42 EDT 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