I have a column with different type of units and want to convert them to the same unit, some of the record have "Varies with device" which I want to keep without touching them
input:
df1["Size"]
output
0 19M
1 14M
2 8.7k
3 25M
4 2.8M
...
10834 2.6M
10836 53k
10837 3.6M
10839 Varies with device
10840 19M
I tried to use this code but it does not working!
def convert_size(x):
if x[-1] == "M":
return str(x[:-1])*1000
else: return x
df1["Size"] = df1["Size"].apply(convert_size)
note: 1000k = 1M