Error at converting series type

At laptops data I am trying to convert euors_price column to float after I replaces “,” with “.” and it is replaced but at converting he is insisting to deal with old value which contains “,” hence raising error cannot convert string to float

Hi @AhmedHatem

Welcome to our DataQuest Community

On seeing above the image, I can say that you are doing correct just a problem of columns here.
In line 29,

laptops["price_euors"] = laptops["price_euros"].str.replace(",","")

You are replacing “,” character with “.” in items of “price_euros” column and assigning it to new column “price_ euors”.
In line 30,

laptops["price_euors"] = laptops["price_euros"].astype(float)

You are tring to convert items of “price_euros” column to float data type, but it raising an error because items of “price_euros” contains “,” character, which can’t be converted into float type.

Finally, what you are doing is replacing “,” from “price_euros” column and assigning it to “price_euors” and trying to convert “price_euros” column into float type, which is not possible because of “,” character.

So, what you have to do is replace “,” character from “price_euros” column and assign it to “price_euros” column then convert it’s data type.

laptops["price_euros"] = laptops["price_euros"].str.replace(",",".")
laptops["price_euros"] = laptops["price_euros"].astype(float)

I am facing a similar problem right now and I don’t know how to go about it because even the solution you gave still returned the same error

Can you post your notebook and the error you are getting?