human
How to group similar items in a list?
assistant
Here is some code to make a list of lists in which each list `g` are the elements from list `test` which have the same characters up to the first `_` character

[list(g) for _, g in itertools.groupby(test, lambda x: x.split('_')[0])]

#Warning: this code generation is experimental. Please inspect the code for any bugs before executing.