0

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 Answer 1

1

Check with isin

df = logins[~logins['user_id'].isin( invalid_users['ID'])]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.