import collections


def transpose_dict(adict):
    """Transposes a dict of dicts to regroup the data."""
    out = collections.defaultdict(dict)
    for k,v in adict.items():
        for ik,iv in v.items():
            out[ik][k] = iv
    return out