0
votes

I have several datasets. One include a list of users, while the others are the activities of said users. The issues is that some of the users needs to be removed (admins, tests users, etc).

## Save users that should be removed
invalid_user = users[(users['E-Code'].isnull())]
## Remove users
user = users.drop(users[(users['E-Code'].isnull())].index)

Now I'm looking to remove the invalid users from other datasets. I cannot use the E-Code column as it is not present in the other datasets, I have to use another ID (unqiue id from a db). Currently, I'm looking into a datasets where the users logins are tracked. What I've tried unsuccessfully:

df = logins[logins['user_id'] != invalid_users['ID']]

and

df = logins['user_id'].drop(invalid_patients['ID])

Since I need to do this several times, I look to create a method once I get it down. I can't share the data, but I could create a example if it's needed.

Thanks!

1

1 Answers

1
votes

Check with isin

df = logins[~logins['user_id'].isin( invalid_users['ID'])]