I am trying to convert the values in a Pandas DataFrame from string to float but am running into an error.
The column looks like this:
PIB (IBGE/2005)
---------------
71.638.000
114.250.000
44.373.000
462.258.000
186.812.000
Where the . are the digit group separators, so 71.638.000 should become the float 71638000.
But I am getting the error:
ValueError: could not convert string to float: '71.638.000'
Here is an image of my full DataFrame:
How can I convert this column from string to float?
71.638.000supposed to be as a float?.in your dataset is a thousand separator, which confuses your parsing library (probably set by default to understand.as the English decimal point). I'd recommend cleaning your data to remove those.pd.read_csv(yourfile, thousands='.')orpd.to_numeric(df[column])