[Numpy-discussion] astype
Nils Wagner
nwagner at iam.uni-stuttgart.de
Sat Feb 14 11:27:28 EST 2009
On Sat, 14 Feb 2009 17:22:43 +0100
"Nils Wagner" <nwagner at iam.uni-stuttgart.de> wrote:
> Hi all,
>
> How can I convert an array with string elements to
> an array with float entries ?
>
>
>
>>>> coord_info[:,1]
> array(['0,0', '100,0', '200,0', '300,0', '400,0',
>'500,0',
> '600,0', '700,0', '800,0', '0.0', '100.0', '200.0',
> '300.0', '400.0', '500.0', '600.0',
> '700.0', '800.0', '0.0', '100.0', '200.0',
> '300.0', '400.0', '500.0', '600.0', '700.0', '800.0',
> '0.0', '100.0', '200.0', '300.0', '400.0',
> '500.0', '600.0', '700.0', '800.0', '0.0',
> '100.0', '200.0', '300.0', '400.0', '500.0', '600.0',
> '700.0', '800.0'],
> dtype='|S50')
>
>>>> coord_info[:,1].astype(float)
> Traceback (most recent call last):
> File "<stdin>", line 1, in <module>
> ValueError: invalid literal for float(): 0,0
>
>
> Nils
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion at scipy.org
> http://projects.scipy.org/mailman/listinfo/numpy-discussion
Sorry for the noise - dots and commas were mixed up in
the input file.
More information about the NumPy-Discussion
mailing list