import collections


def taxonomy_counts(checkins, beerstyle2cat, bid2beer):
    """
    Aggregate beer checkins `checkins` list to given taxonomy `beerstyle2cat`.
    `beerstyle2cat` is a dictionary mapping an Untappd beer style string
    to a taxonomic category.
    """
    counts = collections.Counter()
    for c in checkins:
        beer = bid2beer[c['beer']]
        bstyle = beer['beer_style']
        cls = beerstyle2cat[bstyle]
        counts[cls] += 1
    return counts