def median_plus_error_fmt(row, fmt):
    """
    Function to apply to a `pandas.DataFrame` to transform the `median`,
    `upper_1sigma`, and `lower_1sigma` into a median +/- errors formatted
    string
    """
    args = row['median'], row['upper_1sigma'], abs(row['lower_1sigma'])
    if fmt == 'latex':
        return '\\num{%.7g} \\numpmerr{%.7g}{%.7g}' % args
    elif fmt == 'ipynb':
        return '$%.5g^{+%.2g}_{-%.2g}$' % args
    else:
        raise NotImplementedError(
            'output format `%s` is not valid for `median_plus_error`' % fmt)
