Skip to content
Advertisement

Remove series of characters in pandas

Somewhat of a beginner in pandas.

I am trying to clean data in a specific column by removing a series of characters.

Currently the data looks like this:

JavaScript

I need to remove the (F)

I used … df[‘Column A’]=df[‘Column A’].str.replace(‘[(F)]’,’ ‘)

This successfully removed the (F) but it also removed the other F letters (for example Fried Apples = ied Apples) How can I only remove the “series” of characters.

Advertisement

Answer

Try this –

JavaScript
JavaScript

OR

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