I have a data frame that has 10 columns and 1000 rows. I am trying to merge two specific rows into one single row based on date and ID The data frame is like this
Id Name Product Date revenue
1 John P1 2022-02-01 50
1 John P2 2022-02-01 10
2 Joe P1 2022-01-01 60
2 Joe P2 2022-02-01 10
2 Joe P3 2022-03-01 20
What I want the output as
Id Name Product Date revenue
1 John P1,P2 2022-02-01 60
2 Joe P1,P2,P3 2022-03-01 90
I tried `groupby`, `apply` and `ffill()`. What I am struggling with is to have products as P1,P2,P3 in one single row by their latest date. Any suggestions?