def make_age_sex_map(b01001):
    """Make a map from age and sex to columns in Census table b01001

    Generally, you'll want to use the compiled version in age_sex.py
    """

    t = b01001.stacked(add_dimensions=True)

    t = t[['column', 'sex', 'min_age', 'max_age']].drop_duplicates()

    as_map = {}

    for idx, r in t.iterrows():
        for age in range(r.min_age, r.max_age + 1):
            as_map[(r.sex, age)] = r.column

    return as_map