Suppose I have a dataframe(grouped by ID-A and ID-B) like this-
ID-A ID-B time sum flag
A 1 09:30:00 5 Y
09:33:00 8 N
09:36:00 5 Y
2 09:36:00 10 Y
09:39:00 15 Y
09:42:00 2 Y
B 1 09:30:00 10 Y
09:33:00 12 N
09:36:00 5 Y
I want to calculate the total 'Y' flags against each ID-A and ID-B.
Desired Dataframe-
ID-A ID-B time sum flag(Total)
A 1 09:30:00 5 2
09:33:00 8
09:36:00 5
2 09:36:00 10 3
09:39:00 15
09:42:00 2
B 1 09:30:00 10 2
09:33:00 12
09:36:00 5