How does one group by partial key, where the key is composed of multiple tuples and we want to group by all of them except the first one. Example:
example = {((0, 0), (0, 2)): (-1, 0), ((2, 0), (0, 2)): (1, 0), ((2, 1), (0, 3)): (1,0)}
End result of group by:
first_group = {((0, 0), (0, 2)): (-1, 0), ((2, 0), (0, 2)): (1, 0)}
second_group = {((2, 1), (0, 3)): (1,0)}
Here the key is length 2 and we only groped by second tuple in key. But if the key the length of 3 (n) tuples:
{((0, 0), (0, 2), (0, 3)): (-2, 0)}
I want it to group by the last two (n-1):
(0, 2), (0, 3)
I have looked at this question but I had no luck to apply itertools.groupby to this structure where they key can be composed of multiple tuples.