# Turn the column into delimited string
df = (df.groupby(['NETWORK','config_id'])
.agg({'APPLICABLE_DAYS': lambda x: ",".join(x),'Case':'mean','Delivery':'mean'})
.rename({'Case' : 'Avg_Cases','Delivery' : 'Avg_Delivery'},axis=1)
.reset_index())
df
Out[1]:
NETWORK config_id APPLICABLE_DAYS Avg_Cases Avg_Delivery
0 Grocery 5399 SUN,MON,TUE,WED 25 2.5
# Turn the column into list
df = (df.groupby(['NETWORK','config_id'])
.agg({'APPLICABLE_DAYS': lambda x: x.tolist(),'Case':'mean','Delivery':'mean'})
.rename({'Case' : 'Avg_Cases','Delivery' : 'Avg_Delivery'},axis=1)
.reset_index())
df
Out[1]:
NETWORK config_id APPLICABLE_DAYS Avg_Cases Avg_Delivery
0 Grocery 5399 [SUN, MON, TUE, WED] 25 2.5