I have a dictionary of lists, where the lists represent columns. All the lists are the same length and the number of lists is variable. I want to convert the lists of columns into lists of rows. It doesn't have to end in a dictionary a matrix is perfect; however, I can't use numpy
.
For example: The setup looks something like this
>>> A = [ 1 , 2 , 3 , 4 , 5 , 6]
>>> B = ["A", "B", "C", "D", "E", "F"]
>>> C = ["J", "K", "L", "M", "N", "O"]
>>> d = {"One": A, "Two": B, "Three": C}
do magic here and get the following
[(1, 'A', 'J'), (2, 'B', 'K'), (3, 'C', 'L'), (4, 'D', 'M'), (5, 'E', 'N'), (6, 'F', 'O')]
Notice the first element in the cols are now in a row. Now I can get this by doing
>>> zip(d["One"], d["Two"], d["Three"])
but this would only work if the number of dictionary entries was constant. How can I do this if the number of dictionary entries was variable? Hope I'm clear.