I have a database with over 2 million rows. I'm trying to find rows that contain both of two words using regex like:
df1 = df[df['my_column'].str.contains(r'(?=.*first_word)(?=.*second_word)')]
However, when trying to process this in jupyter notebook, it either takes over a minute to return these rows or it crashes the kernal and I have to try again.
Is there a more efficient way for me to return rows in a dataframe that contain both words?