I have a dataframe like below:
product_id date status
1 2018-09-11 G
1 2016-01-11 B
1 2018-02-11 P
2 2019-06-12 P
2 2020-10-11 P
3 2019-07-21 G
3 2016-09-11 B
3 2018-12-15 B
3 2020-11-07 P
:
:
n 2020-11-11 G
Since I have duplicate product_id, I am thinking to group by the product id and only filter out the earliest date of the corresponding product_id, but my date column is not a datetime object, so I need to convert it to datetime first or I do not have to if there's other way to do it. The output dataframe should look like below:
product_id date status
1 2016-01-11 B
2 2019-06-12 P
3 2016-09-11 B
:
:
n 2020-11-11 G
I am wondering are there any better or faster ways to achieve my goal other than using group by or maybe drop duplicate?