0

Currently i have a big list, of specific UserIds, that i want to select it is specific rows and formulate a df from the conjunction of the filters. I managed to achieve that. But the thing is they way i am currently doing is straight up ugly and lacks interactivity. And since the list of users is going to grow i wish to know a better way to formulate those users. Or just a cleaner way at least For those that are curious, no there is no other way of selecting those specific users.

The current code is as follows:

prod = (df['UserId'] == '[email protected]') | (df['UserId'] == '[email protected]') |(df['UserId'] == '[email protected]') |(df['UserId'] == '[email protected]')
df[prod]
INGl0R1AM0R1
  • 1,532
  • 5
  • 16

1 Answers1

0

If you have a big list of user ids you want to check, use .isin to filter out your dataframe:

userids = ['[email protected]',
           '[email protected]',
           '[email protected]',
           '[email protected]']

prod = df[df['UserId'].isin(userids)]
Corralien
  • 109,409
  • 8
  • 28
  • 52