Session Ready
Exercise

Using pandas functionality: groupby

This course will focus on the spatial functionality of GeoPandas, but don't forget that we still have a dataframe, and all functionality you know from Pandas is still applicable.

In this exercise, we will recap a common functionality: the groupby operation. You may want to use this operation when you have a column containing groups, and you want to calculate a statistic for each group. In the groupby() method, you pass the column that contains the groups. On the resulting object, you can then call the method you want to calculate for each group. In this exercise, we want to know the size of each group of type of restaurants.

We refer to the course on Manipulating DataFrames with pandas for more information and exercises on this groupby operation.

Instructions
100 XP
  • Using groupby(), group the restaurants by the type of restaurants, and calculate the size of each group. Call the result type_counts.
  • Print the resulting Series.