Hi all. With the current version in order to achieve filtering that is reversed to 'pd.Series.isin()' we need to define a function or use a lambda, ie:

df = df[df['city'].apply(lambda x: 'TA' in x if x is not None else False)]

I tought it could be a bit easier if we could have a syntax like:

df = df['TA' is in df['city']]

I believe this will involve overriding __contains__ in pd.Series.

Comment From: shoyer

Note that is in is not valid Python syntax -- the correct operator is simply in.

Unfortunately, the result of Python's in operator is always cast to a boolean. So I'm afraid there's nothing we can do make this work with pandas.

Also, even if this was possible, it would be a major backwards compatibility break -- we already use in to return a boolean indicating whether an element is found in a Series or not:

>>> -1 in pd.Series(range(3))
False

Comment From: jorisvandenbossche

@DeepSpace2 apart from what @shoyer explained you about the in operator, there is already a rather convenient method to achieve this kind of in filtering (if I understand the case correctly):

df[df['city'].str.contains('TA')]

This is equivalent to the apply example you gave.