Groups of data can be selectively dropped from processing using .filter(). This method is supplied a function that can be used to make group-level decisions on whether the entire group is included in the result after the combination. The function should return True if the group is to be included in the result and False to exclude it.
We will examine several scenarios using the following data:
The first demonstration will drop groups that do not have a minimum number of items. Specifically, they will be dropped if they only have one item or less:
The following example will omit groups that have any NaN values: ...