I have a dataframe with duplicates in "Model Number". I want to keep each row that has "Difference" equaling 0.00 and remove its duplicate, but if a duplicate pair does not have a "Difference" equaling 0.00 then I don’t want to remove it.
Original Dataframe
Thank you for your help.
>Solution :
Try the following code;
df1 = df[df["Difference"] == 0]
lst_model = [i for i in df["Model Number"].unique() if i not in df1["Model Number"].unique()]
df2 = df[df["Model Number"].isin(lst_model)]
df_final = pd.concat([df1,df2])