2017-11-15 1 views

Antwort

0

Dict-Mapping mit .str Accessor wird d.h

di = {'M':10**3,'G':10**6 } 

df[['c','d']] = df[['c','d']].apply(lambda x : pd.to_numeric(x.str[:-1]) * x.str[-1].map(di)).astype(str) + 'KB' 
 
    b    c    d 
0 abc 12800000.0KB 12600000.0KB 
1 def  2670.0KB 3400000.0KB 
2 ghi 12500000.0KB  34500.0KB 
3 jkl 12100000.0KB 1200000.0KB 

helfen Wenn Sie dann

df[['c','d']].apply(lambda x : pd.to_numeric(x.str[:-1]) * x.str[-1].map(di)).astype(int) 
+0

und wenn wir wollen nur den ganzzahligen Teil benutzen Sie einfach die ganze Zahl brauchen !! – madhuri

+0

Sie brauchen nur die ganze Zahl? – Dark

+0

yeah ich brauche nur ganzzahl Teil – madhuri

Verwandte Themen