I am trying to search for words in string account lock
in text encoded as Pandas Series.
Currently, I am using contains
function.
If text is account lock email
I am getting correct results.
>>> pd.Series('account lock email').str.contains('account lock', case=False)
0 True
dtype: bool
But if text is lock email account
I am getting result False
.
>>> pd.Series('lock email account').str.contains('account lock', case=False)
0 False
dtype: bool
Also if text is account email lock
I am getting result False
.
>>> pd.Series('account email lock').str.contains('account lock', case=False)
0 False
dtype: bool
Is there any way that contains
function can be used to check if all words in a specified string are present in Pandas Series?
Or is there any alternative?
Got required results using below code using all function
>>> all(x in ('lock email account').split() for x in ('account lock').split())
True
>>> all(x in ('account email lock').split() for x in ('account lock').split())
True
>>> all(x in ('account email').split() for x in ('account lock').split())
False