Given a list_of_list from a SQL table, I'd like to analyze sets of adjacent rows dividing list_of_list for equal elements of column 2, then for equal element of column 1. For example, given
list_of_list = [[1,1,3,2],
[1,3,3,2],
[1,3,6,2],
[1,3,6,2],
[1,5,5,2],
[1,3,5,2]]
I'd like to get to following output
[1,1,3,2]
[1,3,3,2]
[1,3,6,2]
[1,3,6,2]
[1,5,5,2]
[1,3,5,2]
What's wrong in the following code?
for key1, items1 in groupby(list_of_list, itemgetter(2)):
for key2, items2 in groupby(items1, itemgetter(1)):
for i in items2:
print(i)
print
it returns the following output
[1,1,3,2]
[1,3,3,2]
[1,3,6,2]
[1,3,6,2]
[1,5,5,2]
[1,3,5,2]
list_of_listand expected output? Likeprint(i)and tell us what it's supposed to print.