Assuming I've the following pandas.Series:
import pandas as pd
s = pd.Series([1,3,5,True,6,8,'findme', False])
I can use the in
operator to find any of the integers or Booleans. Examples, the following all yield True:
1 in s
True in s
However, this fails when I do:
'findme' in s
My workaround is to use pandas.Series.str
or to first convert the Series to a list and then use the in
operator:
True in s.str.contains('findme')
s2 = s.tolist()
'findme' in s2
Any idea why I can't directly use the in
operator to find a string in a Series?