I am trying to get the different required combinations out from dataframe column with few rows.It is something like below:
I have following values in one of the columns of my df
G1,g2 - group 2,
A1 to a4 - group 3,
R1 to r3 - group 4,
L1,l2 - group 5,
A5,a6 - group 6
Oy g1 a1
Oy g1 a1 r1
Oy g1 a1 r1 l1
Oy g1 a1 r1 l1 a5
I think you may want to
itertools.product on the various groupings.
To get the groups you could do
first_letter = df[col].str.str.lower() groups = df[col].groupby(first_letter).unique()
col here is the name of the column describe above).
This gives a mapping from the first letter (lowercase) to an array of the unique values starting with that letter (lower or upper case). Then you can do
itertools.product(*groups) to get all six-tuples containing one member from each group.
To get all combinations of, say, the g and o groups, you can do