DataPipeline/Utilities.py
def arrangeDictbySecondaryKey(data, labels, sep='__'):
    """Re-arrange a dict of dicts by each records secondary keys"""

    newdata = {}
    if not type(data) is types.DictType:
        return data
    key1 = data.keys()[0]
    if type(data[key1]) is types.DictType:
        fields = data[key1].keys()
    for f in fields:
        newdata[f] = {}
    for f in fields:
        for d in data.keys():
            #print d
            lbl = labels[d]
            if data[d].has_key(f):
                xy = data[d][f]
                newdata[f][lbl] = xy
    return newdata
Re-arrange a dict of dicts by each records secondary keys
Re-arrange a dict of dicts by each records secondary keys
Re - arrange a dict of dicts by each records secondary keys
def arrangeDictbySecondaryKey(data, labels, sep='__'):
    newdata = {}
    if not type(data) is types.DictType:
        return data
    key1 = data.keys()[0]
    if type(data[key1]) is types.DictType:
        fields = data[key1].keys()
    for f in fields:
        newdata[f] = {}
    for f in fields:
        for d in data.keys():
            lbl = labels[d]
            if data[d].has_key(f):
                xy = data[d][f]
                newdata[f][lbl] = xy
    return newdata
def arrangeDictbySecondaryKey ( data , labels , sep = '__' ) : newdata = { } if not type ( data ) is types . DictType : return data key1 = data . keys ( ) [ 0 ] if type ( data [ key1 ] ) is types . DictType : fields = data [ key1 ] . keys ( ) for f in fields : newdata [ f ] = { } for f in fields : for d in data . keys ( ) : lbl = labels [ d ] if data [ d ] . has_key ( f ) : xy = data [ d ] [ f ] newdata [ f ] [ lbl ] = xy return newdata
Re-arrange a dict of dicts by each records secondary keys
Re - arrange a dict of dicts by each records secondary keys
"""Re-arrange a dict of dicts by each records secondary keys""" #print d
data
labels
sep