group_vars = ['a'] df.merge( df.drop_duplicates( group_vars ).reset_index(), on=group_vars ) a b index 0 1 1 0 1 1 1 0 2 1 2 0 3 2 1 1 4 2 1 1 5 2 2 1