dropping duplicates by a column but excluding nan stack overflow code example Example: drop duplicate rows pandas except nan df[(~df.duplicated()) | (df['col'].isnull())]