'Filter groups in the Table based on evaluating function ``func`` on each
group sub-table.
The function which is passed to this method must accept two arguments:
- ``table`` : `Table` object
- ``key_colnames`` : tuple of column names in ``table`` used as keys for grouping
It must then return either `True` or `False`.  As an example, the following
will select all table groups with only positive values in the non-key columns::
def all_positive(table, key_colnames):
colnames = [name for name in table.colnames if name not in key_colnames]
for colname in colnames:
if np.any(table[colname] < 0):
return False
return True
Parameters
func : function
Filter function
Returns
out : Table
New table with the aggregated rows.'

def filter(self, func):

    mask = np.empty(len(self), dtype=np.bool)
    key_colnames = self.key_colnames
    for (i, group_table) in enumerate(self):
        mask[i] = func(group_table, key_colnames)
    return self[mask]
