# Buggy code
def filter(self, func, dropna=True, *args, **kwargs):
    """
    Return a copy of a Series excluding elements from groups that
    do not satisfy the boolean criterion specified by func.

    Parameters
    ----------
    func : function
        To apply to each group. Should return True or False.
    dropna : Drop groups that do not pass the filter. True by default;
        if False, groups that evaluate False are filled with NaNs.

    Example
    -------
    >>> grouped.filter(lambda x: x.mean() > 0)

    Returns
    -------
    filtered : Series
    """
    if isinstance(func, compat.string_types):
        wrapper = lambda x: getattr(x, func)(*args, **kwargs)
    else:
        wrapper = lambda x: func(x, *args, **kwargs)

    indexers = [
        self.obj.index.get_indexer(group.index) if wrapper(group) else []
        for _, group in self
    ]

    if len(indexers) == 0:
        filtered = self.obj.take([])  # because np.concatenate would fail
    else:
        filtered = self.obj.take(np.concatenate(indexers))
    if dropna:
        return filtered
    else:
        return filtered.reindex(self.obj.index)  # Fill with NaNs.


# Traceback (ValueError)
In [90]: dff = pd.DataFrame({'A': np.arange(8), 'B': list('aabbbbcc'), 'C': np.arange(8)})

In [91]: dff.groupby('B').filter(lambda x: len(x) > 2)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-91-89d79df28299> in <module>()
----> 1 dff.groupby('B').filter(lambda x: len(x) > 2)

C:\Anaconda\lib\site-packages\pandas\core\groupby.pyc in filter(self, func, dropna, *args, **kwargs)
2092                 res = path(group)
2093
-> 2094             if res:
2095                 indexers.append(self.obj.index.get_indexer(group.index))
2096

ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()


In [93]: pd.__version__
Out[93]: '0.12.0'

# Fixed code
def filter(self, func, dropna=True, *args, **kwargs):
    """
    Return a copy of a Series excluding elements from groups that
    do not satisfy the boolean criterion specified by func.

    Parameters
    ----------
    func : function
        To apply to each group. Should return True or False.
    dropna : Drop groups that do not pass the filter. True by default;
        if False, groups that evaluate False are filled with NaNs.

    Example
    -------
    >>> grouped.filter(lambda x: x.mean() > 0)

    Returns
    -------
    filtered : Series
    """
    if isinstance(func, compat.string_types):
        wrapper = lambda x: getattr(x, func)(*args, **kwargs)
    else:
        wrapper = lambda x: func(x, *args, **kwargs)

    # Interpret np.nan as False.
    def true_and_notnull(x, *args, **kwargs):
        b = wrapper(x, *args, **kwargs)
        return b and notnull(b)

    try:
        indexers = [
            self.obj.index.get_indexer(group.index) if true_and_notnull(group) else []
            for _, group in self
        ]
    except ValueError:
        raise TypeError("the filter must return a boolean result")
    except TypeError:
        raise TypeError("the filter must return a boolean result")

    if len(indexers) == 0:
        filtered = self.obj.take([])  # because np.concatenate would fail
    else:
        filtered = self.obj.take(np.concatenate(indexers))
    if dropna:
        return filtered
    else:
        return filtered.reindex(self.obj.index)  # Fill with NaNs.