Pandas group by and sum two columns

后端 未结 3 501
鱼传尺愫
鱼传尺愫 2021-01-12 09:43

Beginner question. This seems like it should be a straightforward operation, but I can\'t figure it out from reading the docs.

I have a df with this structure:

3条回答
  •  温柔的废话
    2021-01-12 10:37

    You just need to call sum on a groupby object:

    df.groupby('integer_id').sum()
    

    See the docs for further examples

提交回复
热议问题