course content

Course Content

Data Manipulation using pandas

Advanced Aggregation [2/2]Advanced Aggregation [2/2]

Great! What is you need to apply certain functions to specific columns separately, like find out median of one column, and mean of another one. Surely, you can perform grouping twice. But this case is also covered by pandas and .agg() method. If you want to apply specific functions to certain columns, pass them as a dictionary {'column': 'function'}. For instance, we can calculate mean total income ('totinch') and median number of people in a dwelling ('hhsize') for each number of bedrooms.

Note that if you pass dictionary as the .agg() method parameter, then there is no need to select columns after grouping.

Section 4.

Chapter 3