I want to search for specific words in one string in my dataset. I already know how to search for these words separately, but now I only want to search for strings that contain both words.
This is my script when I search for separate words, for example ‘hello’ and ‘goodbye’. This also returns strings with only the word ‘hello’ in it:
df_return=df[df['openfield'].str.contains("hello|bye")==True]
How can I change this script in order to return only the strings that contains both the words somewhere in this string? And not the strings that only contain one of the two words?