O'Reilly logo

Learning pandas - Second Edition by Michael Heydt

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Grouping by a single column's values

The sensor data consists of three categorical variables (sensor, interval, and axis) and one continuous variable (reading). It is possible to group by any single categorical variable by passing its name to .groupby(). The following code groups the sensor data by the values in the sensor column:

The result of .groupby() on a DataFrame is a subclass of a GroupBy object, either a DataFrameGroupBy for a DataFrame or a SeriesGroupBy for a Series. This object represents an interim description of the grouping that will eventually be performed. This object helps pandas to first validate the grouping relative to ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required