So let's say I have some data as follow:
patient_id  lab_type  value
1           food       10
1           food       8
2           food       3
2           food       5
1           shot       4
1           shot       10
2           shot       2
2           shot       4
Then I will group things such as groupby(['patient_id', 'lab_type'])
After that, I'd like to aggregate on value but different for each lab_type. On food I'd like to aggregate using mean and on shot I'd like to aggregate using sum.
The final data should look like this:
  patient_id  lab_type  value
  1           food       9 (10 + 8 / 2)
  2           food       4 (3 + 5 / 2)
  1           shot       14 (10 + 4)
  2           shot       6 (2 + 4)
 
     
     
     
     
    