Lets say I have the following dataframe -
import pandas as pd
df = pd.DataFrame({'c1': ['a', 'a', 'a', 'b', 'b', 'c'], 'c2': ['x', 'y', 'z', 'y', 'x', 'x'], 'c3': [1, 2, 3, 4, 5, 2]})
c1 c2 c3
0 a x 1
1 a y 2
2 a z 3
3 b y 4
4 b x 5
5 c x 2
by df.groupby(['c1', 'c2']).mean()
it produces
which is fine, but would require in the form as the image.