[Tutor] Get all possible ranges of columns across a dataframe's
marc nicole
mk1853387 at gmail.com
Thu Mar 30 16:14:41 EDT 2023
I have this dataframe:
12 2 17
16 4 16
2 19 11
I want to get, accross its columns, the following output
[
> [12,16,2],[2,4,19],[17,16,11],[[12,16,2],[2,4,19]],[[2,4,19],[17,16,11]],[[12,16,2],[2,4,19],[17,16,11]]
> ]
I have this code which yield the first 3 possibilities only:
>
>
>
>
>
>
>
> *from itertools import combinations resultTmp2 = [] for j in
> range(1, len(dataframe.columns) + 1): resultTmp = [] for
> xVal in list(combinations(dataframe.iloc[:len(dataframe) + 1,j-1],
> len(dataframe) )): resultTmp.append(list(xVal))
> resultTmp2.append(resultTmp) print(resultTmp2)*
How to update my code so that it yields correct mentioned output?
More information about the Tutor
mailing list