I have the following dataframe badges
from which I want to create a subset badges_gold
. The condition of subset is that the UserId
present in badges
should be present in the list gold_users
. But when I use is in
operation I get invalid syntax
error. How to fix this?
Main Dataframe - badges
UserId | Name
1 | Altruist
2 | Autobiographer
3 | Enlightened
4 | Citizen Patrol
5 | python
List of Gold Badge Users - gold_users
gold_users = [1,2,3]
Code
badges_gold = badges[badges.UserId is in gold_users]
Expected Output - badges_gold
UserId | Name
1 | Altruist
2 | Autobiographer
3 | Enlightened
Error
SyntaxError: invalid syntax