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.
>Solution :
You can use groupby_last:
out = df.groupby('user')['friend'].last().reset_index()
Output:
user friend
0 One Two
1 Three Two.