0

I have a DataFrame as follows:

item_id | item_count | day | month
   1    |     2      |  1  |   1
   2    |     1      |  1  |   2
...

The dataframe tells what is the item_id and how many it is sold item_count per day, and in which month. I want to get the item_count of every item_id per month. I think I have to groupby both item_id and month, but which of the first seems to give the wrong result. How do I do that?

Minh-Long Luu
  • 2,393
  • 1
  • 17
  • 39

1 Answers1

1

i used groupby but i am getting the result that you seem to be expecting - here is what i have done.

df.groupby(['item_id ',' month']).sum()

is this what you were looking for ?

Bharath
  • 406
  • 2
  • 13