od = OrderedDict()
for name, group in df.groupby(['code', 'colour']):
    temp = group[['id', 'amount']].sort(['amount'], ascending=[0]).to_dict()
Pandas: transforming the DataFrameGroupBy object to desired format