Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

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')
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #pandas #remove #duplicate #rows #nan
ADD COMMENT
Topic
Name
2+4 =