Python Group By Function Power