combines the result for
    each group together into a new series:

    >>> g.apply(lambda x:  x*2 if x.name == 'b' else x/2)
    0    0.0
    1    0.5
    2    4.0
    dtype: float64

    Example 2: The function passed to ``apply`` takes a series as
    its argument and returns a scalar. ``apply`` combines the result for
    each group together into a series, including setting the index as
    appropriate:

    >>> g.apply(lambda x: x.max() - x.min())
    a    1
    b    0
    dtype: int64
    )