Introduction to Grouping

In this lesson, you will be introduced to the concept of grouping related items in Pandas.


The ability to group or segment DataFrames by one or more columns is one of the key features of any data analysis application. Therefore it would most likely show up in a data analysis interview or task.

The idea is to divide a DataFrame into multiple groups to analyze each group separately.


As a reminder, the syntax is as simple as df.groupby(<col_name>) or, in the case of grouping by multiple columns, df.groupby([<col1>, <col2>, ..]).

Operations such as aggregations and apply functions can be applied on DataFrameGroupBy objects which can be reset to a normal DataFrame using reset_index()

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy