I want to add the particular columns (C, D, E, F, G) based on the duplicate rows of column B. Whereas the remaining non-duplicate rows unchanged. The output of column A must be the first index of duplicate rows.
I have a dataframe as follows:
A B C D E F G
box1 0487 1 1 1
box2 0487 1 1
blue 0478 1 1 1
gray 0478 1 1 1 1
gray 0478 1 1 1
flat 8704 1 1 1
clay 8704 1 1
dark 8740 1 1 1 1 1
late 4087 1 1 1
I want the output as follows:
A B C D E F G
box1 0487 1 1 1 1 1
blue 0478 2 2 2 2 2
flat 8704 1 1 1 2
dark 8740 1 1 1 1 1
late 4087 1 1 1
I am pleased to hear some suggestions.