0

I wanted to convert all my columns from "object" dataype to "float" so I used this code

  df1 = num.apply(lambda x: pd.to_numeric(x.astype(str).str.replace(',',''), 
   errors='coerce'))

but this changed two columns into very small deminal values which is wrong

|  Population   | Total Test  |
| --------------|-------------|
|  3.348053e+08 | 1.159833e+09|
|  1.406632e+09 | 9.152658e+08|

I have tried removing the '.' point with this code but its not working.

df1[['Total Test', 'Population']] = df1[['Total Test', 'Population']].replace('.','')
Ynjxsjmh
  • 28,441
  • 6
  • 34
  • 52

0 Answers0