yes male no yes in [ ]grouped agg({'tip_pct['min''max''mean''std']'size'sum'}out[ ]tip_pct size min max mean std sum sex smoker female no yes male no yes dataframe will have hierarchical columns only if multiple functions are applied to at least one column returning aggregated data in "unindexedform in all of the examples up until nowthe aggregated data comes back with an indexpotentially hierarchicalcomposed from the unique group key combinations observed since this isn' always desirableyou can disable this behavior in most cases by passing as_index=false to groupbyin [ ]tips groupby(['sex''smoker']as_index=falsemean(out[ ]sex smoker total_bill tip size tip_pct female no female yes male no male yes of courseit' always possible to obtain the result in this format by calling reset_index on the result using groupby in this way is generally less flexibleresults with hierarchical columnsfor exampleare not currently implemented as the form of the result would have to be somewhat arbitrary group-wise operations and transformations aggregation is only one kind of group operation it is special case in the more general class of data transformationsthat isit accepts functions that reduce one-dimensional array to scalar value in this sectioni will introduce you to the transform and apply methodswhich will enable you to do many other kinds of group operations supposeinsteadwe wanted to add column to dataframe containing group means for each index one way to do this is to aggregatethen merge data aggregation and group operations www it-ebooks info