transposelist#

class transposelist(obj, fix_uneven=True)[source]#

Convert e.g. a list of key-value tuples into a list of keys and a list of values.

Parameters:
  • obj (list) – the list-of-lists to be transposed

  • fix_uneven (bool) – append None values where needed so all input lists have the same length

Examples:

o = sc.odict(a=1, b=4, c=9, d=16)
itemlist = o.enumitems()
inds, keys, vals = sc.transposelist(itemlist)

listoflists = [
    ['a', 1, 3],
    ['b', 4, 5],
    ['c', 7, 8, 9, 10]
]
trans = sc.transposelist(listoflists, fix_uneven=True)

New in version 1.1.0.