def _convert_method_arg(method):
    """
    Convert argument `method` to a function that can be called after
    resampling or reindexing a DataFrame. If `method` is a string such
    as 'ffill' or 'bfill' then it will be converted to a function. Otherwise
    if `method` is itself a callable function, then it will be used directly.

    For example, the string 'ffill' is converted to a lambda-function `func`
    so that `func(df.resample(rule))` actually performs the chained
    function-call `df.resample(rule).ffill()`

    :param method: String or callable function.

    :return: Callable function.
    """

    if method == 'ffill':
        # Forward fill.
        func = lambda x: x.ffill()
    elif method == 'bfill':
        # Backward fill
        func = lambda x: x.bfill()
    elif method == 'linear':
        # Linear interpolation.
        func = lambda x: x.interpolate(method='linear')
    elif method == 'quadratic':
        # Quadratic interpolation.
        func = lambda x: x.interpolate(method='quadratic')
    elif method == 'mean':
        # Averaging which is useful in downsampling.
        func = lambda x: x.mean()
    elif callable(method):
        # Use the provided callable method directly.
        func = method
    else:
        # Raise exception because of invalid arg.
        msg = 'arg `method` must either be a valid string or a callable function.'
        raise ValueError(msg)

    return func