df_tr = pd.DataFrame({'Col1':[1,2,1,2,2],
'Col2':[5,5,5,6,6],
'aCol':[1,8,9,6,4]})
print(df_tr)
Col1 Col2 aCol
0 1 5 1
1 2 5 8
2 1 5 9
3 2 6 6
4 2 6 4
# multiply 10 in you solution
df_tr_mod = df_tr.groupby(['Col1','Col2']).aCol.agg(['count']) * 10
print (df_tr_mod)
count
Col1 Col2
1 5 20
2 5 10
6 20
print (type(df_tr_mod))
<class 'pandas.core.frame.DataFrame'>
#For MultiIndex, add to_frame
df_tr_mod = df_tr.groupby(['Col1','Col2']).size().to_frame(name='count') * 10
print (df_tr_mod)
count
Col1 Col2
1 5 20
2 5 10
6 20
#Add reset_index() for all columns from index
df_tr_mod = df_tr.groupby(['Col1','Col2']).size().reset_index(name='count')
df_tr_mod["count"]= df_tr_mod["count"]*10
print (df_tr_mod)
Col1 Col2 count
0 1 5 20
1 2 5 10
2 2 6 20