pandas cumulative sum of partial elements with groupby,df['*PtsPerOrder*'] = df.groupby('OrderNum')['PtsPerLot'].transform(sum)