pandas drop duplicates keep based on column not null code example Example: drop duplicate rows pandas except nan df[(~df.duplicated()) | (df['col'].isnull())]