June 2017
Beginner to intermediate
446 pages
9h 23m
English
A common transformation in statistical analysis with grouped data is to replace missing data within each group with the mean of the non-NaN values in the group. To demonstrate this, the following code creates a DataFrame with a Label column with two values (A and B) and a Values column containing a series of integers, but with one value replaced with NaN. The data is then grouped by the Label column:

The mean of each group can be calculated using .mean():

Now suppose that we need the B group ...
Read now
Unlock full access