Skip to content
Advertisement

replace() removes the whole word not the character

I have a dataframe with prices in $. I want to do calculations on it but the $ makes it impossible. I’m trying to remove it using df.iloc[:, 4].replace("$", " ", regex=True) but unfortunately nothing changes. If I add inplace=True then whe whole word disappears. What am I doing wrong? Tried many stackoverflow posts but nothing works. I cant use str.replace() because its about the whole column not one word.

My code:

JavaScript

Then I call function replace() but the table stays the same: df.iloc[:, 4].replace("$", " ", regex=True)

Thanks in advance

Advertisement

Answer

JavaScript

Alternatively:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement