If I have the following code:
df_ = df_[df_['summary'].str.contains('slow delivery', na=False)]
df_ = df_['summary']
print(df_)
And the following list:
df_ = ['May be great product, but slow delivery is annoying',
'May be great product, but slow delivery is annoying',
'slow delivery',
'Great product, slow delivery',
'smewhat slow delivery but accurate and wellpackeged. thank you!']
But I want to select all the items in the list that contain a combination of slow and delivery, instead of 'slow delivery'.
How does the above need to be adjusted?
Thanks in advance.
CodePudding user response:
Might as well just make separate masks for both words in this case. If you have a longer list of words, there are better solutions.
df_ = df_[df_['summary'].str.contains('slow') & df_['summary'].str.contains('delivery')]