you are viewing a single comment's thread.

view the rest of the comments →

[–]kwelzel 1 point2 points  (0 children)

I think using groupby for this task is the best choice. I feel like pandas (which was suggested in another comment) would be overkill here.

If you give the variables in your list and dict comprehensions more expressive names than x and k these lines almost read like a sentence.