def var_mapper(data, mapping):
    """
    Map data column values to generated values

    Parameters
    ----------
    data : DataFrame
        The DataFrame to access data from
    mapping : dict
        A nested dictionary where the top-level keys are the column
        names.  The values are a dictionary where the keys are
        the variable to generate and the values are dictionaries
        with the old-value / new-value pairs.

    Returns
    -------
    dict of lists

    """
    out = {}
    for col, attrs in mapping.items():
        for aname, attrmap in attrs.items():
            if isinstance(attrmap, dict):
                out[aname] = list(data[col].map(attrmap))
            else:
                out[aname] = list(attrmap(data[col]))
    return out
