Home > Enterprise >  how to extract recent data and delete previous data if more column have same value
how to extract recent data and delete previous data if more column have same value

Time:04-20

input data frame(input data have duplicates with some columns ,wants to delete previous data)

output should be

CodePudding user response:

According to your input and output I think you want to remove duplicate rows:

cols = ['col1', 'col2']
df_output = df_input.drop_duplicates(cols, keep='last')

You'll have to specify which columns to use, I'm not sure from your example which columns define duplicates

  • Related