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

Viewed 22

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?

1 Answers

Try this:

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