How to do it...

  1. Read in the college dataset, and find a few basic summary statistics on the undergraduate population and SAT math scores by institution and religious affiliation:
>>> college = pd.read_csv('data/college.csv')>>> cg = college.groupby(['STABBR', 'RELAFFIL']) \                ['UGDS', 'SATMTMID'] \                .agg(['size', 'min', 'max']).head(6)
  1. Notice that both index levels have names and are the old column names. The column levels, on the other hand, do not have names. Use the rename_axis method to supply level names to them:
>>> cg = cg.rename_axis(['AGG_COLS', 'AGG_FUNCS'], axis='columns')>>> cg
  1. Now that each axis level has a name, reshaping ...

Get Numerical Computing with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.