I wanted to get the mean, stp, skewness from any score column, while I grouped my data set be 2 other columns (group, block). I used this code for it -
scores_list = ['A','B','C']
descriptive_agg = df.groupby(['group','block'])[scores_list].agg(['mean', 'std','skew'])
and got this dataFrame:
A A A B B B C C C
mean std skew mean std skew mean std skew
group block
0 neg 26.76470588 54.79291496 6.069163775 3.098039216 1.170553749 0.114238196 1.738755233 0.611860454 1.063953504
0 neu 29.92 70.9644464 6.275474539 3.6 1.245399698 -0.039619494 1.906404475 0.568964543 0.561075178
1 neg 16.42391304 18.0702133 2.968326848 2.891304348 1.253185144 0.209586627 1.684455875 0.598785419 0.872917578
1 neu 16.92391304 18.49159815 2.951129818 3.5 1.172018077 -0.313988331 1.893045967 0.646930842 1.11778034
But I want to have a "score" column on the left, my expected output is:
Score group block mean std skew A 0 neg 26.76470588 54.79291496 6.069163775 0 neu 29.92 70.9644464 6.275474539 1 neg 16.42391304 18.0702133 2.968326848 1 neu 16.92391304 18.49159815 2.951129818
B 0 neg 3.098039216 1.170553749 0.114238196 0 neu 3.6 1.245399698 -0.039619494 1 neg 2.891304348 1.253185144 0.209586627 1 neu 3.5 1.172018077 -0.313988331
thanks in advance!