I know it is not a problem per se but I think there should be some pandas built in solution for this problem, as no simple function exists for this. It is largely discussed here with various ideas (https://stack
GROUP BY Column1, Column2 We aim to make operations like this natural and easy to express using pandas. We’ll address each area of GroupBy functionality then provide some non-trivial examples / use cases. See thecookbookfor some advanced strategies. 2 Splitting an object into groups pandas o...