I have a pandas dataframe that has a list of user identifiers 'subscriber_id' and other information.
I want to select only subscribers not on this list A.
So, if our data frame contains information for subscribers [1,2,3,4,5], and my list of exceptions is [2,4,5], now I should get an information frame with information for [1,3]
I tried using the mask as follows:
temp = df.mask(lambda x: x['subscriber_id'] not in subscribers)
but no luck!
I am sure it not inis a valid Python syntax since I tested it on a list like this:
c = [1,2,3,4,5]
if 5 not in c:
print 'YAY'
>> YAY
Any suggestion or alternative way to filter a data frame?
source
share