Let's suppose I have a dataset like this:
item_id | date | cat |
----------------------------
0 | 2020-01-01 | A |
0 | 2020-02-01 | B |
1 | 2020-04-01 | A |
2 | 2020-02-01 | C |
2 | 2021-01-01 | B |
So, I need to get the last category (column cat), that means that the result dataframe would be the following:
item_id | cat |
---------------
0 | B |
1 | A |
2 | B |
I know I could sort the values by the date and then iterate over the itens, but that would be too much consuming. Is there another method on pandas to achieve that?