0

I have been trying to change the words in one of the columns of my data frame such that it will replace all the words except some keywords which I want to leave as it is. I tried doing this:

df['col]=df['col].where(lambda x: x == ('A'or'B'or'C'),'others')

My plan is to replace every word that isn't A or B or C with others. The code worked for A but B and C were replaced. How do I go about this please?

NB: I am trying to improve my python skill and have searched the entire stack-overflow before asking this question. Thank you for your help.

ayhan
  • 70,170
  • 20
  • 182
  • 203
RichAd
  • 29
  • 1
  • 8

0 Answers0