Given a table with many columns
|-------|-------|-------|-------|
| A | B | .. | N |
|-------|-------|-------|-------|
| 1 | 0 | .. | X |
| 2 | 0 | .. | Y |
| .. | .. | .. | .. |
|-------|-------|-------|-------|
What is the most efficient way to iterate over all column combinations (of all length) and perform a GROUP BY operation? As the table and esp. combinations can be quite large (2^n), preferable with GPU support.
colnames = df.columns
for L in range(2,len(colnames)):
for comb in itertools.combinations(colnames, L):
dfg = df.groupby(comb, sort=False).size().reset_index().rename(columns={0:'count'})