examplein the above data setto compute means for just the data column and get the result as dataframewe could writein [ ]df groupby(['key ''key '])[['data ']mean(out[ ]data key key one two one two the object returned by this indexing operation is grouped dataframe if list or array is passed and grouped series is just single column name that is passed as scalarin [ ]s_grouped df groupby(['key ''key '])['data 'in [ ]s_grouped out[ ]in [ ]s_grouped mean(out[ ]key key one two one two namedata grouping with dicts and series grouping information may exist in form other than an array let' consider another example dataframein [ ]people dataframe(np random randn( )columns=[' '' '' '' '' ']index=['joe''steve''wes''jim''travis']in [ ]people ix[ : [' '' ']np nan add few na values in [ ]people out[ ] joe - steve - - - wes - nan nan - - jim travis - - - - - nowsuppose have group correspondence for the columns and want to sum together the columns by groupin [ ]mapping {' ''red'' ''red'' ''blue'' ''blue'' ''red'' 'orange'groupby mechanics www it-ebooks info