I have a few columns that have numerical data with commas (eg. the number is stored as '4,200' and hence not being read as a number) in base file. To able to process the data I need to remove these commas from multiple columns of data.
import pandas as pd
import numpy as np
df = {'INR': ['4,200','5,000',0,'4,353','6,000',1],
'USD':['4,100','3,000','1,000','4,353','6,000',1]}
df = pd.DataFrame(df)
If I write the following line of code it works:
df['INR']=df['INR'].replace(',','').astype(int)
But the following line of code doesn't:
df[['INR','USD']]=df[['INR','USD']].replace(',','').astype(int)
Would be great if someone can help understand why
df[['INR','USD']].replace(',', '', regex=True)