Mean

We can find the mean values for the numerical column in each group. This can be done using the df.mean() method.

The code for finding the mean is as follows:

# mean() will print mean of numerical column in each group
style.mean()

The output of the preceding code is as follows:

Note that we can get the average of each column by specifying a column, as follows:

# get mean of each column of specific group
style.get_group("convertible").mean()

The output of the preceding code is as follows:

Next, we can also count the number of symboling/records in each group. To do so, use the following code:

# get the number of symboling/records in each group
style['symboling'].count()

The output of the preceding code is as follows:

body-style
convertible 6
hardtop 8
hatchback 68
sedan 94
wagon 25
Name: symboling, dtype: int64

Having understood the counting part, in the next section, we are going to discuss different types of data aggregation techniques.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.251.56