drop duplicate rows pandas except nan
df[(~df.duplicated()) | (df['col'].isnull())]
drop duplicate rows pandas except nan
df[(~df.duplicated()) | (df['col'].isnull())]
pandas remove duplicate rows least nan
# drop duplicate rows having the least null values
# (assuming 'col_1' is the column from which you want to remove the duplicates)
new_df = df.sort_values(by=list(df.columns), na_position='last').drop_duplicates('col_1', keep='first')
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us