Pandas currency strings: Strip USD, then astype(float) and sum

Pandas currency strings: Strip USD, then astype(float) and sum

I used Python Pandas to total AWS S3 payments.

Data was in a CSV file. But numbers in the “Amount” column were written as “USD 12.34”.

Here’s what I did:

(
    df['Amount']
    .str.replace('USD', '') # remove "USD"
    .astype(float)          # no strip needed!
    .sum()
)