Intermediate Python and Pandas/
My Code: <laptops[“weight”].str.replace(“kg”,"").str.replace(“kgs”,"").astype(float)>
this one is not letting me change to float value…
Replace this line with your code
What I expected to happen:
What actually happened:
Replace this line with the output/error
The posted link points to a wrong page. Could you post the correct link?
Hello @mansi.trivedi, welcome to the community!
The error is in the order of your
The correct line of code is:
str.replace("kgs","") comes before
str.replace("kg","") in this line of code, this way the
kgs substring is first replaced in the string before the
kg substring is replaced.
I hope this helps.