0

I have a reference dataframe and I want to use it to replace any strings from str1 and str2 columns(possible to have duplicates) in a text column from another dataframe by the string in the "to_be_replaced" column. For example,

enter image description here

enter image description here

Thank you so much!

lionking19063
  • 79
  • 1
  • 7
  • Does this answer your question? [Use dictionary to replace a string within a string in Pandas columns](https://stackoverflow.com/questions/46342492/use-dictionary-to-replace-a-string-within-a-string-in-pandas-columns) – G. Anderson Aug 11 '22 at 21:29
  • It's not clear what went wrong with your attempts. When I create the dictionary from your examples, as `{'house':'home','apartment':'home','hotel':'home','nice':'great','awesome':'great','good':'great'}`, then running the code from the marked duplicate outputs "you are so great. great to see you" in my console – G. Anderson Aug 11 '22 at 22:51

0 Answers0