0

i have a df that has this:

ID Date Amount
1234 1/2/23 12
5678 1/2/23 34
5678 1/2/23 56
9012 1/2/23 70

I am trying to get the sum of 'Amount' and the count of 'Date':

ID Count(Date) Sum(Amount)
1234 1 12
5678 2 90
9012 1 70

I have tried varies groupby's, agg's, and similar but can't seem to figure it out.

How do I do this?

rhs
  • 17
  • 5
  • 1
    `df.groupby("ID").agg({"Date":"count", "Amount":"sum"})` – Andrej Kesely Jul 07 '21 at 20:34
  • 1
    thanks andrej. just fyi, i tried many of the solutions in the posted answer and 1 did not work for me and another threw an error. your solution above does work. perhaps i had mistyped something – rhs Jul 07 '21 at 21:18

0 Answers0