I have the following code snippet that is quite inefficient: It aims to produce 27 different combinations of exactly 3 numbers for each combination
nums = [i for i in range(1,4)]
combinations = []
for i in nums:
for j in nums:
for k in nums:
combinations.append([i,j,k])
This generates 27 combinations which is correct.
Is there a more efficient way to generate this and how can I store into a dataframe instead of a list ?