0

Hi stackoverflow community, i'm using this dataframe:

Client          Date     Amount 
Jack      10/01/2020        100
Jack      10/01/2020        200
Jack      10/01/2020        300
Jack      10/01/2020        400
Jack      12/01/2020        100
Jack      12/01/2020        100
Jack      13/01/2020        100

What i have noticed in pandas groupby that shows only the result without column name and i really want to have the column name to refere it in upcoming actions

What i've tried ?

result=df.groupby(["Client", "Date"])["Amount"].sum()
Client          Date     
Jack      10/01/2020        1000
Jack      12/01/2020        200
Jack      13/01/2020        100

Desired Results

 Client          Date         Amount
    Jack      10/01/2020        1000
    Jack      12/01/2020        200
    Jack      13/01/2020        100

1 Answers1

0

Try:

result=df.groupby(["Client", "Date"])["Amount"].sum().reset_index()
Learning is a mess
  • 7,479
  • 7
  • 35
  • 71