Combining Distinct Combinatios Of Elements Of An Numpy Array Into A Dataframe
Maybe I could synthesize precisely my problem with my title, however I guess that by explaning it, things will get more clear. So, what I want to do is the following: I want to cre
Solution 1:
Use itertools.product for cartesian product, last pass it to DataFrame constructor:
from  itertools import product
df = pd.DataFrame(list(product(*[x1_set,x2_set,x3_set,x4_set])))
print (df)
       0    1    2    3
0    1.0  1.0  1.0  1.0
1    1.0  1.0  1.0  2.0
2    1.0  1.0  1.0  3.0
3    1.0  1.0  1.0  4.0
4    1.0  1.0  1.0  5.0
..   ...  ...  ...  ...
620  5.0  5.0  5.0  1.0
621  5.0  5.0  5.0  2.0
622  5.0  5.0  5.0  3.0
623  5.0  5.0  5.0  4.0
624  5.0  5.0  5.0  5.0
[625 rows x 4 columns]
Post a Comment for "Combining Distinct Combinatios Of Elements Of An Numpy Array Into A Dataframe"