1

I load the dataset to my program like ___.csv.

there are column's element of 3,123, 22,458, 5,237 string-type number, I trying to convert them into float64 type using astype(np.float64), but it says we can't convert str type into float64 type, for example:

could not convert string to float: '234,262,829'

can anyone tell me how to solve it? thanks!!

Mark Tolonen
  • 166,664
  • 26
  • 169
  • 251
Jonny CasHsu
  • 31
  • 1
  • 3
  • Remove the commas. – BoarGules May 26 '22 at 17:39
  • Does this answer your question? [Convert commas decimal separators to dots within a Dataframe](https://stackoverflow.com/questions/31700691/convert-commas-decimal-separators-to-dots-within-a-dataframe) or [Pandas read_csv - thousands separator working inconsistent](https://stackoverflow.com/questions/42098982/pandas-read-csv-thousands-separator-working-inconsistent) – ti7 May 26 '22 at 17:40
  • 1
    the `,` is a decimal point? – WhiteAB May 26 '22 at 17:40
  • @WhiteAB this appears to be in the american numbering system where comma is a thousands separator, given the example in the error `'234,262,829'` – G. Anderson May 26 '22 at 17:48

0 Answers0