Answers for "pandas remove duplicate rows least nan"

1

drop duplicate rows pandas except nan

df[(~df.duplicated()) | (df['col'].isnull())]
Posted by: Guest on December-08-2020
0

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')
Posted by: Guest on March-01-2022

Code answers related to "pandas remove duplicate rows least nan"

Python Answers by Framework

Browse Popular Code Answers by Language