Suppose the following data frame with one column called < game >:
df:
game
0 juegos blue
1 juego red
2 juegos yellow
I would like to remove the words from the following list of stop words:
stopWords = ['juego','juegos']
and the desired result is:
df:
game
0 blue
1 red
2 yellow
I tried that:
df['game'] = df['game'].str.replace("|".join(stopWords ), " ")
The function works but it removes 'juego' from the entry "juegos" leaving an 's' alone:
df:
game
0 s blue
1 red
2 s yellow
Is there a way to remove words only if there is an exact match?