So, I have a pandas column name Notes which contains a sentence or explanation of some event. I am trying find some given words from that column and when I find that word I am adding that to the next column as Type
The problem is for some specific word for example Liar, Lies its picking up word like familiar and families because they both have liar and lies in them.
Notes Type
2 families are living in the address Lies
He is a liar Liar
We are not familiar with this Liar
As you can see from above only the second sentence is correct. How do I only pick up separate word like liar, lies and not families or familiar.
This was my approach,
word= ["Lies"]
for i in range(0, len(df)):
for f in word:
if f in df["Notes"][i]:
df["Type"][i] = "Lies"
Appreciate any help. Thanks