1

I have a column with data as:

1           77M
2        118.5M
3           72M
4          102M
5           93M
6           67M

I need to change this to its numerical value as:

77,000,000

and so on.

I have tried different ways but could not come up with a definite solution.

tawab_shakeel
  • 3,701
  • 10
  • 26

1 Answers1

0

okay this should work

(df[1].str.replace('M','').astype(float) * 1000000).astype(int).astype(str).apply(lambda x : x[:-6]+','+x[-6:-3]+','+x[-3:])

Output

0     77,000,000
1    118,500,000
2     72,000,000
3    102,000,000
4     93,000,000
5     67,000,000
Name: 1, dtype: object
iamklaus
  • 3,720
  • 2
  • 12
  • 21