so I am trying to make a boolean search program. The user enters a keyword (at most 3) to search in my dataframe. So, to search the keyword in my columns, I am using .loc and this does return the keyword but it also returns similar words too. For example:
The user enters the keyword - tweet
the result shows - tweet and tweeted
Dataframe has 4 columns (One_key, Two_key, Three_key, link). 10 keywords in each _key column. I am taking data from some text files but this is the format.
,One_key,Two_key,Third_key,link
0,parliament,laws,agricultural,www.xyz.com
1,population,supreme court,ampc,www.zyx.com
2,protest,road,blockades,www.fdw.com
3,violence,tweeted,batons,www.jsa.com
4,Rihanna,tweet,government, www.xyz.com
5,barbadian,Chris Brown,together, www.ici.com
if x == '1':
print("enter the word to search:")
y = input()
print("Your search result: \n", keyword.loc[(keyword.One_key.str.contains(y, ))
| (keyword.Two_key.str.contains(y))
| (keyword.Third_key.str.contains(y))])
What should I use to get the exact word?