I have a column in a data frame with the following left side format. I reckon that because of the ,
and the $
symbol the column has a string
format, but I want to convert it into float, in order to manipulate the data.
I have used the two following lines of code to strip those characters, hoping it would convert the column values into floats.
sales_dataset_date['invoice_value2'] = sales_dataset_date['invoice_value'].replace('$', '')
sales_dataset_date['invoice_value2'] = sales_dataset_date['invoice_value'].replace(',', '')
After I run the above commands, I get the following output:
|invoice_value |invoice_value2 |
| $55.87 | $55.87 |
| $28,852.37 | $28,852.37 |
| $1,392.00 | $1,392.00 |
I can't convert it into float. There is no difference with the replace
command. What I am doing wrong? How can I fix it?