I'm using the pandas df.str.replace() function and would like to remove multiple characters from the string.
I'm trying to clean up some transaction data in a CSV file using pandas. I have a column that is storing the amount of the transaction as an Object data type. Before I can change it to a float datatype, I need to remove the $ character and any , characters from numbers greater than 999.99. I've been able to do this one at a time; however, I'd like to know if I can pass in multiple values to clean it up.
2 8/20/2019 Utah Valley Univ UTAH VALLEY UNIV UVU PMT 1 908191 4,825.50
df['Amount'] = df['Amount'].str.replace(r',','').astype(float)
I'd like to remove the '$' and the ',' character at the same time if possible.
df['Amount'] = df['Amount'].str.replace(r'\$|\,', '').astype(float)?