'How can i get a aggregate sum of Average number of product given between two weeks and output for Each week as shown below in Pandas?

StartWeek End Week Numberof Week Number of Product Avg number of product per week
39 41 3 99 33
40 45 5 150 30
40 42 3 60 20
39 40 2 40 20
39 41 3 99 33

So that the output looks like --

Week Sum Average Product per week
39 86
40 70
41 66
42 20
45 30


Solution 1:[1]

you can use the group by method in python df=df.groupby(["StartWeek"])["Avg number of product per week"].sum()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 noob