Exploring Ebay Car Sale Data. your feedback is needed

Ebay exercise
Hi hi, I have a little problem with a string to float conversion and I look no matter what I admit it remains a dilemma, in the following line of code :

autos['price'] = autos['price'].str.replace('$' , '').str.replace(',', ' ') .astype(float, errors = 'raise') 

the system sends me back :

ValueError: could not convert string to float: '5 000'

Is there someone with the same problem to tell me what to do.

By the way I have already tried the lines of codes such as:

df['a'] = pd.to_numeric(df['a'],errors = 'coerce')

Thanks

Hi @stephan.mastail and welcome to the community!

I think I can see what is causing this error with what you have provided however, I can’t be sure. Can you please follow these guidelines for future posts: Guidelines for asking a technical question in our Community, specifically to include a link to the mission screen so that we “helpers” can get some context to your problem.

That said, based on the error you’ve provided, I believe what’s causing your problem here is the space between the leading 5 and the trailing 000. If you tried to convert the string “5000”, I don’t think you’d get an error like you are for “5 000”. Similarly, you’d get an error if you tried to convert “$5,000” to a float. Can you see how you can modify your code slightly so that $5,000 becomes 5000 rather than 5 000?

Let me know if that makes any sense and if not, we can try something else to figure this out together.