I have a data frame df
df = pd.DataFrame([["A","X",98,56,61], ["B","E",79,54,36], ["A","Y",98,56,61],["B","F",79,54,36], ["A","Z",98,56,61], ["A","W",48,51,85],["B","G",44,57,86],["B","H",79,54,36]], columns=["id","class","c1","c2","c3"])
when we do groupby on id, if duplicate values(rows) are present based on multiple columns like c1,c2,c3, retain the row based on weighatge given on column class.
For example here when we do groupby on id A, c1,c2,c3 are duplicates for class X,Y,Z, among X,Y,Z weighatge given to X so retain X and delete other rows, similarly among E,F,H weightage given to F, so retain F and delete other rows.
Expected Output:
output = pd.DataFrame([["A","X",98,56,61],["B","F",79,54,36],["A","W",48,51,85],["B","G",44,57,86]], columns=["id","class","c1","c2","c3"])
How to do it?