def _transpose_iterables(fields, values):
 if isinstance(values, dict):
  transposed = dict([(field, defaultdict(list)) for field in fields])
  for (key, tuples) in list(values.items()):
   for kvals in tuples:
    for (idx, val) in enumerate(kvals):
     if (val is not None):
      transposed[fields[idx]][key].append(val)
  return list(transposed.items())
 else:
  return list(zip(fields, [[v for v in list(transpose) if (v is not None)] for transpose in zip(*values)]))

def _transpose_iterables ( fields , values ) : if isinstance ( values , dict ) : transposed = dict ( [ ( field , defaultdict ( list ) ) for field in fields ] ) for ( key , tuples ) in list ( values . items ( ) ) : for kvals in tuples : for ( idx , val ) in enumerate ( kvals ) : if ( val is not None ) : transposed [ fields [ idx ] ] [ key ] . append ( val ) return list ( transposed . items ( ) ) else : return list ( zip ( fields , [ [ v for v in list ( transpose ) if ( v is not None ) ] for transpose in zip ( * values ) ] ) )
converts the given fields and tuple values into a standardized iterables value .