top grouped apply(get_top if you prefer do-it-yourself approachyou could also dopieces [for yeargroup in names groupby(['year''sex'])pieces append(group sort_index(by='births'ascending=false)[: ]top pd concat(piecesignore_index=truethe resulting data set is now quite bit smallerin [ ]top out[ ]int index entries to data columnsname non-null values sex non-null values births non-null values year non-null values prop non-null values dtypesfloat ( )int ( )object( we'll use this top , data set in the following investigations into the data analyzing naming trends with the full data set and top , data set in handwe can start analyzing various naming trends of interest splitting the top , names into the boy and girl portions is easy to do firstin [ ]boys top [top sex =' 'in [ ]girls top [top sex =' 'simple time serieslike the number of johns or marys for each year can be plotted but require bit of munging to be bit more useful let' form pivot table of the total number of births by year and namein [ ]total_births top pivot_table('births'rows='year'cols='name'aggfunc=sumnowthis can be plotted for handful of names using dataframe' plot methodin [ ]total_births out[ ]int index entries to columns entriesaaden to zuri dtypesfloat ( in [ ]subset total_births[['john''harry''mary''marilyn']in [ ]subset plot(subplots=truefigsize=( )grid=falsetitle="number of births per year" introductory examples www it-ebooks info