def ld2dl(d):
    """ List of dict to dict of list. """
    if not d:
        return d
    d_out = {k: [] for dd in d for k in dd.keys()}
    for o in d:
        for k, v in o.items():
            d_out[k].append(v)
    return d_out