I would be very grateful for the contribution made to my question - it may not seem that it works. I need to iterate over the list of tuples, for example:
li = [('a',1),('b',2),('c', 2),('d', 2), ('e', 3), ('f', 3), ('g', 1)]
and would like to get the result, for example:
new_li = [('a', 1), ('bcd',2), ('ef',3), ('g',1)]
where I concatenate rows based on the second value in the tuple. I do not want to use groupbyout itertools, because although gconnected with 1, it is not immediately next to a. Thanks for all the answers!
source
share