I need to convert a data frame column containing a string to a float.
Typical string contains "," separators e.g. "1,000.00", so the commas need to be stripped out.
This does not work
dataframe.sales_aud = dataframe.sales_aud.replace(",", "")
dataframe.astype({"units": int, "sales_aud": float})
Error below:
ValueError Traceback (most recent call last)
<ipython-input-9-669177671309> in <module>
17 dataframe.sales_aud = dataframe.sales_aud.replace(",", "")
18
---> 19 dataframe.astype({"units": int, "sales_aud": float})
20
21 dataframe.to_pickle("weekly_sales_2020.csv")
....
ValueError: could not convert string to float: '1,088'