I have a dataframe which looks like this:
ID Date Volume Sales
0 1 2019-01-01 3.333333 1.333333
1 1 2019-02-01 3.333333 1.333333
2 1 2019-03-01 3.333333 1.333333
3 1 2019-04-01 2.666667 2.000000
4 1 2019-05-01 2.666667 2.000000
5 1 2019-06-01 2.666667 2.000000
6 2 2019-01-01 2.000000 2.666667
7 2 2019-02-01 2.000000 2.666667
8 2 2019-03-01 2.000000 2.666667
9 2 2019-04-01 1.333333 3.333333
10 2 2019-05-01 1.333333 3.333333
11 2 2019-06-01 1.333333 3.333333
I would like to sum up the data (volume and sales) on a set of dates within each group (ID).
From 2019-01-01 to 2019-04-01 AND 2019-02-01 to 2019-05-01
I believe this can be done using for loops, but struggling to get the desired outcome
Note: Question may be phrased poorly. Please comment if you have any additional questions
Excepted output:
ID Date Volume Sales
1 2019-01-01 to 2019-04-01 12.67 6
1 2019-02-01 to 2019-05-01 12 6.66
2 2019-01-01 to 2019-04-01 7.33 11.33
2 2019-02-01 to 2019-05-01 6.66 12
Having the date column in the output is not necessary