[Numpy-discussion] Convert array type

Adam Mercer ramercer@gmail....
Sat Oct 6 22:35:06 CDT 2007


Hi

I am fairly new to using numpy and am running into a problem regarding
the type of an array.  The array in question is created using the
following code:

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)

but that results in the error:

ValueError: setting an array element with a sequence.

Cheers

Adam


More information about the Numpy-discussion mailing list