In the weight column row 1061 there is an entry “4s” and it throws off the solution. Anybody else having the same issue? This makes my mission incomplete.
Hi Parimal. There was a hint in the page about cleaning the weight column, and I suspect this may be the issue you’re having:
While it appears that the
weight column may just need the
kg characters removed from the end of each string, there is one special case - one of the values ends with
kgs , so you’ll have to remove both
I hope that helps!
Hi April, my code below removes the “kg” and “kgs” but I noticed that I get the same error when I submit the code written below. I get the correct answer when I replace “kgs” first. Do you know why this is?
laptops[“weight”] = laptops[“weight”].str.replace(“kg”,"").str.replace(“kgs”,"").astype(float)
Hi @joeauyeung, welcome to the community!
When you remove ‘kg’ first, it will also remove the ‘kg’ from ‘kgs’, leaving behind just the ‘s’. Then when it then searches for ‘kgs’, it cannot be found because all that’s left is ‘s’. That’s why we want to remove the ‘kgs’ first, and then the ‘kg’, so that we avoid running into this problem.