How to remove the currency in the dataframe in pandas?

Viewed 46

here are the data frame look like

CCD     CFO     CP3     DHC     ERS     FRO     HDI     IHI     IPI     ODF     PAE  
                       0 EGP           40 USD          210 USD  
inclu                         1500 THB                 70 INR          855 EUR
       inclu                                   60 CNY

The first line is the column name, what I want to do is to remove the currency and keep the number and 'inclu'. Calculate the total number of each row.

1 Answers

Use DataFrame.replace for remove space(s) or uppercase strings to end of value in all columns:

df = df.replace(r'(\s+[A-Z]+)$', '', regex=True)
Related