renaming columns after group by and sum in pandas dataframe

前端 未结 2 1923
星月不相逢
星月不相逢 2021-02-14 01:49

This is my group by command:

pdf_chart_data1 = pdf_chart_data.groupby(\'sell\').value.agg([\'sum\']).rename(
    columns={\'sum\':\'valuesum\',\'sell\' : \'sellt         


        
2条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-14 02:40

    df = df.groupby('col1')['col1'].count()
    df1= df.to_frame().rename(columns={'col1':'new_name'}).reset_index()
    

提交回复
热议问题