Reputation: 53
I have a table like this
user | friend | food |
---|---|---|
One | Two | apple |
Three | Four | hello |
Three | Two. | hey. |
My desired output is this
user | friend |
---|---|
One | Two |
Three | Two. |
Thanks.
Upvotes: 0
Views: 79
Reputation:
You can use groupby_last
:
out = df.groupby('user')['friend'].last().reset_index()
Output:
user friend
0 One Two
1 Three Two.
Upvotes: 3