How to check if keyword is present in title or not in Python?

109 views Asked by At

I have a dataset which contains multiple keywords and I want to check if title contains the same key or not. it should be row by row partial match.

I have tried this code but it is not working for indic words/keys:

for string in df['key']:
    test = df['title'].str.contains(string,case=False, na=False) 
    print(test)

Sample dataset:

dataset

Expected Output:

output

1

There are 1 answers

0
apiuser On BEST ANSWER

I don't have Indic keyboard, but have you tried the easy solution:

for line in list_of_lines:
    if str(line['key']).lower() in str(line['title']).lower():
        print('True')
    else:
        print('False')