Javascript Array Reduce Group By In Python