December 2018
Beginner to intermediate
682 pages
18h 1m
English
It is possible to apply our customized function to multiple aggregating columns. We simply add more column names to the indexing operator. The max_deviation function only works with numeric columns:
>>> college.groupby('STABBR')['UGDS', 'SATVRMID', 'SATMTMID'] \ .agg(max_deviation).round(1).head()

You can also use your customized aggregation function along with the prebuilt functions. The following does this and groups by state and religious affiliation:
>>> college.groupby(['STABBR', 'RELAFFIL']) \ ['UGDS', 'SATVRMID', 'SATMTMID'] \ .agg([max_deviation, 'mean', 'std']).round(1).head()
Notice that pandas uses the name of the ...
Read now
Unlock full access