I have a Dataframe that looks like this:
prod_id, prod_name, col_1, col_2, type
101, electronic, 10, 10, old
102, hardware, 2, 4, old
101, electronic, 10, 10, new
102, hardware, 2, 1, new
103, other, 22, 13, new
I am trying to update my Dataframe such that the updated Dataframe has the row with type=old if all other columns are same else using value from type=new
Final output:
prod_id, prod_name, col_1, col_2, type
101, electronic, 10, 10, old
102, hardware, 2, 1, new
103, other, 22, 13, new
Dataframe.drop_duplicatesmethod? It takes asubsetparametersubsetparameter?type) are same, then I would prefer to take the first occurrence. If the values in any of the columns have a mismatch then I would like to take the latest row. On the other question, I did try df.drop_duplicates(subset=['col_1','col_2']) would perform the duplicate elimination but I am trying to have a check on type column before applying thedrop_duplicatesmethod