I perform some non-trivial aggregation as in the following:
aggregations = {
'x_TmId': {
'Trays': 'nunique',
'Orderlines': 'count',
},
'x_Qty': 'sum'
}
newdf = pick.groupby(['Date','x_OrderId']).agg(aggregations).reset_index(True)
at this point the aggregated dataframe columns can be called as usual by
newdf.columns
but that returns something I did not encounter before: a MultiIndex object:
MultiIndex(levels=[['x_TmId', 'x_Qty', 'x_OrderId'], ['Orderlines', 'Trays', 'sum', '']],
labels=[[2, 0, 0, 1], [3, 0, 1, 2]])
At this point, I realize I don't know how to call as example the new variables "sum"? There must be some similar question on stackoverflow, but could not find it yet.