How to group by one column or another in pandas
I have a table like: col1 col2 0 1 a 1 2 b 2 2 c 3 3 c 4 4 d I’d like rows to be grouped together if they have a matching value in col1 or col2. That is, I’d like something like this: > ( df .groupby(set(‘col1’, ‘col2’)) # Made-up syntax .ngroup())… Read More How to group by one column or another in pandas