I'm trying to make a new Dataframe based on a permutation of another Dataframe. Here is the original Dataframe. Price is the index.
df1
Price Bid Ask
1 .01 .05
2 .04 .08
3 .1 .15
. . .
130 2.50 3.00
The second Dataframe is meant to take the index from df1 and create a Dataframe (df2) with permutations of df1 index based on 4 prices such as in the example output below.
df2
# price1 price2 price 3 price 4
1 1 2 3 4
2 1 2 3 5
3 1 2 3 6
.. .. .. .. ..
To achieve this, I've been using itertools.permutation, but I'm having memory issues and cannot execute the huge number of permutations. This is the code I've been using to make the permutations.
price_combos = list(x for x in itertools.permutations(df1.index, 4))
df2 = pd.DataFrame(price_combos , columns=('price1', 'price2', 'price3', 'price4'))