Say I have a given dataframe as below
input = pd.DataFrame({"id":[1,1,1,2,2,3,3,3,3,3], "values":["l", "m", "c", "l", "l", "l", "l", "c","c", "c"]})
and I wanted to remove the extra transactions after "c" appear for an id. say for id 3, the 1st 2 values are "l" and after that all transactions are value c so I only want the 1st c.
output = pd.DataFrame({"id":[1,1,1,2,2,3,3,3], "values": ["l", "m", "c", "l", "l", "l", "l", "c"]})
I tried to do drop_duplicates on a group by but it is not working as per my expectation:
input.groupby("id").drop_duplicates("values")