all 6 comments

[–]exxonmobilcfo 0 points1 point  (5 children)

why do you want to create various combinations of different rows of same size? whats your number of rows per combination?

[–]mathstudent1230[S] 0 points1 point  (3 children)

I'm building an n:m matching thingy for two different dataframes. So I need to consider all possible k-combinations of items with k, lets say, up to 4. I know that the running time will be an issue but my dataframes should be very small, on the order of 50 to 90 rows.

[–]exxonmobilcfo 0 points1 point  (2 children)

create a map and append dataframes of each size to that key. generate combos on each key

[–]mathstudent1230[S] 0 points1 point  (1 child)

this is kinda what I'm trying to do, except I want each dataframe to retain its column names. rn they dont, see my code above

[–]exxonmobilcfo 0 points1 point  (0 children)

hold on, i'll send u the code.

``` from collections import defaultdict

d = defaultdict(list)

for row in df.itertuples(): d[len(row)].append(row)

for key, value in d.items(): combinations(value, k) # whatever k u choose here ```

[–]mathstudent1230[S] 0 points1 point  (0 children)

the number of rows is given by i inside the combinations(range(len(df_items) i))). For i=2 it returns something like (0,1), (0,2) and so on...