I have a dataframe column of strings. Now I want to replace specific words in these strings with a value from another dataframe which has the meaning of the word to be replaced. I am currently using iterrrows() which takes about 2 minutes for 25000 rows. I would like to know if there is a more efficient way of doing this.
syn = pd.ExcelFile("C:/Key-Value.xlsx")
df_syn = syn.parse("Keys")
for idx, row in df_syn.iterrows():
df['col'] = df['col'].str.replace(r"\b"+row['synonym']+r"\b", row['word'])