I have a dataframe which gives me the daily quantity levels of various articles. I want to get a dataframe which gives me the quantity levels on the last day of every month of each article.
OriginaL df:
| item | Date | Quantity |
|---|---|---|
| apple | 23/09/21 | 2143 |
| bat | 21/09/2021 | 2444 |
| cola | 15/09/21 | 1512 |
| apple | 21/10/21 | 2906 |
| bat | 4/10/21 | 2730 |
| cola | 16/10/21 | 2449 |
| cola | 31/12/2021 | 0 |
| apple | 27/12/2021 | 1086 |
| bat | 25/12/2021 | 1186 |
| apple | 26/12/2021 | 1377 |
Target df:
| item | Date | Quantity |
|---|---|---|
| cola | 31/12/2021 | 0 |
| apple | 27/12/2021 | 1086 |
| bat | 25/12/2021 | 1186 |
Is there any way to obtain it?
I tried group by item and date with tail() but it didn't work.