I have a data frame like this:
MONTH STORECODE VALUE GRP
0 0 7 0 0
1 0 7 44 0
2 0 7 12 0
3 0 8 26 0
4 0 8 13 0
5 0 8 0 0
6 2 0 149 0
7 2 0 14 0
8 2 0 0 0
9 2 1 76 0
10 2 1 87 0
I want output data frame like this:
MONTH STORECODE VALUE GRP
0 0 7 56 0
1 0 8 39 0
2 2 0 163 0
3 2 1 163 0
I.e. merge rows into a single on adding VALUE's value if the other 3 values are the same.
For the first row in output, as the first 3 rows in the input df have the same values other than the VALUE's value, these 3 merged into a single row and VALUE's value updated on taking the sum of corresponding values (0+44+12=56)
.