def zip_namedtuple(nt_list):
    """ accept list of namedtuple, return a dict of zipped fields """
    if not nt_list:
        return dict()
    if not isinstance(nt_list, list):
        nt_list = [nt_list]
    for nt in nt_list:
        assert type(nt) == type(nt_list[0])
    ret = {k : [v] for k, v in nt_list[0]._asdict().items()}
    for nt in nt_list[1:]:
        for k, v in nt._asdict().items():
            ret[k].append(v)
    return ret
def zip_namedtuple ( nt_list ) : if not nt_list : return dict ( ) if not isinstance ( nt_list , list ) : nt_list = [ nt_list ] for nt in nt_list : assert type ( nt ) == type ( nt_list [ 0 ] ) ret = { k : [ v ] for k , v in nt_list [ 0 ] . _asdict ( ) . items ( ) } for nt in nt_list [ 1 : ] : for k , v in nt . _asdict ( ) . items ( ) : ret [ k ] . append ( v ) return ret
accept list of namedtuple, return a dict of zipped fields