I have a dataframe with categorical features and values features. Value features are always lists with the exact same size (let's say 3 for the example). So the dataframe is:
Sub Model iter key l1 l2 l3
01 b 0 0 [8,8,5] [3,8,1] [6,7,8]
01 b 1 1 [4,3,6] [3,4,0] [4,0,4]
01 b 2 2 [0,1,4] [0,0,5] [8,2,3]
03 b 3 0 [1,8,2] [4,6,0] [1,3,9]
03 b 4 1 [7,3,1] [6,8,1] [6,7,9]
03 b 5 2 [1,1,0] [11,4,8] [8,5,9]
I want to group the dataframe by [sub,model], such that in each row I will take the mean over the values of the columns key.
So I will get:
Sub Model l1 l2 l3
01 b [4, 4, 5] [2,2,2] [6,3,5]
03 b [3, 4, 1] [7,6,3] [3,5,9]
What will be the best way to do so?