Is there a faster way to generate all permutations for all rows of a pandas DataFrame (and get it back as a dataframe)?
My current approach looks like this:
dataframe = pd.DataFrame(columns=["RX1", "RX2", "RX3", "RX4", "module"])
for idx, row in df.iterrows():
vals = row.values
for permutation in itertools.permutations(vals[0:4], 4):
data = np.stack(permutation)
dataframe.loc[len(dataframe)] = {
"RX1": data[0], "RX2": data[1], "RX3": data[2], "RX4": data[3],
"module": df.iloc[0]["module"]
}
But it takes quite a bit of time. Is there a faster way to do this?