I have multiple records for each patient but I want to keep the old records of different drugs by Date. Suppose patient AB1 has drug ABC on 1st of July and then the same drug on 5th of July, so I want to keep the date of 1st July and delete the rest repating drugs at different dates. Below is the example of target and resultant data frame.
Pat_ID Date Code Drug_Names
AB1 2010-12-09 1.1.1 Alpha
AB1 2010-12-15 1.1.1 Alpha
AB1 2010-12-15 1.1.1 Beta
Ax2 2010-12-09 1.1.1 Beta
Ax2 2010-12-17 1.1.1 Beta
Aq3 2011-02-09 1.1.1 Gamma
Aq3 2011-04-25 1.1.1 Gamma
Aw4 2011-04-25 1.1.1 Tango
Resultant Dataframe below.
Pat_ID Date Code Drug_Names
AB1 2010-12-09 1.1.1 Alpha
AB1 2010-12-15 1.1.1 Beta
Ax2 2010-12-09 1.1.1 Beta
Aq3 2011-02-09 1.1.1 Gamma
Aw4 2011-04-25 1.1.1 Tango