I want to change a column from str to float. The column has now numbers with suffix 'M' or 'K' which I want to remove and keep only the number, and a string which I want to replace to 0.
1) In order to remove the chars M and K, I used it:
apps["Size"] = apps["Size"].map(lambda x: x.lstrip('M').rstrip('M'))
apps["Size"] = apps["Size"].map(lambda x: x.lstrip('K').rstrip('K'))
2) In order to change the value from "Varies with device" to 0, I tried using this:
mask = apps["Size"] == 'Varies with device'
apps.loc[mask, apps["Size"]] = '0'
What am I doing wrong? Is the any easier way to change it?
Thanks!