My dataframe has 3 columns. ID, Day Type (Monday = 0, Sunday = 6), and quantity.
I want to groupby in a way that for each 'Id' I would have 2 rows, one with aggregate quantity of weekdays (M-F) and one for weekend.
Id  Qty  DayType
B07 581  0
B07 1096 1
B07 1245 2
B07 1080 3
B07 856  4
B07 581  5
B07 1096 6
B08 1345 0
B08 1580 3
B08 816  4
Expected output
Id  Qty  DayType
B07 4858 0
B07 1677 1
B08 3741 0
The 0 in the DayType in the output indicates weekday and 1 indicates weekend.
Also, if you can suggest how to pivot it later, that will be even much helpful
id weekday weekend
B07 4858    1677
B08 3741    0
I found a few solutions to groupby based on a condition but in this condition there are two conditions which I cannot figure out how to implement. Thank you.
Based on the answer suggested by Ansev, I am getting following output -
Id  Weekdays  Weekend
B07     20817     3607
C03     22289     6569
F05     22807     6474
That is correct.
But when I try non-pivot format based on Ansev suggestion in the comment under his answer, I get this -
id        Qty        DayType
B07       20817       43
B07        3607       44
C03       22289       43
C03        6569       44
F05       22807       43
As you can see it is adding up DayType too. I expect 0 and 1 there to represent weekday and weekend. Any suggestion?
 
     
    