I'm trying to convert multiple columns of dollar amount into float, and wrote the following code
for column in wo.columns[14:21]:
column = (column.replace( '[\$,)]','', regex=True )
.replace( '[(]','-', regex=True ).replace('#NAME?','NaN', regex=True).astype(float))
return column
And this is the error i get:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-276-f7c13cb3d0af> in <module>
1 for column in wo.columns[14:19]:
----> 2 column = (column.replace( '[\$,)]','', regex=True )
3 .replace( '[(]','-', regex=True ).replace('#NAME?','NaN', regex=True).astype(float))
4 return column
5
TypeError: replace() takes no keyword arguments
What might be wrong? wo is the name of the dataframe, the library i used to load the dataframe was Pandas, and when i used the code on other individual columns it worked fine, just when i used a for loop it return an error.