prof31
prof31

Reputation: 85

Get column groups that have a change in value in other column pandas

I have a large dataset, have a column with usernames and other column for their status.

username  status  
 John      TRUE
 John      TRUE
 John      FALSE
 Mike      FALSE
 ...        ...

I want to see if a user's status changes and who that user is. I don't know where to start, how can I achieve this?

Upvotes: 0

Views: 34

Answers (1)

rhug123
rhug123

Reputation: 8768

Try this:

df.groupby('username')['status'].nunique().loc[lambda x: x.gt(1)].index

Upvotes: 1

Related Questions