def add_a_g_error(df):
    """Extract lerr and uerr of a_g from percentiles.

    Returns df with a_g_lerr, a_g_uerr columns added.
    """
    df = df.copy()
    lerr = df["a_g_val"] - df["a_g_percentile_lower"]
    uerr = df["a_g_percentile_upper"] - df["a_g_val"]
    df["a_g_lerr"], df["a_g_uerr"] = lerr, uerr
    return df