How to sum in pandas by unique index in several columns?

前端 未结 3 1795
耶瑟儿~
耶瑟儿~ 2021-02-04 09:32

I have a pandas DataFrame which details online activities in terms of \"clicks\" during an user session. There are as many as 50,000 unique users, and the dataframe has around 1

3条回答
  •  迷失自我
    2021-02-04 10:11

    suppose your dataframe name is df, then do the following

    df.groupby(['User_ID']).sum()[['User_ID','clicks']]
    

提交回复
热议问题