converting currency with $ to numbers in Python pandas

@EdChum’s answer is clever and works well. But since there’s more than one way to bake a cake…. why not use regex? For example:

df[df.columns[1:]] = df[df.columns[1:]].replace('[\$,]', '', regex=True).astype(float)

To me, that is a little bit more readable.

Leave a Comment