- 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)
- 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
- Now that each axis level has a name, reshaping ...
Get Numerical Computing with Python now with O’Reilly online learning.
O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.