I have a numpy array. What is the fastest way to calculate all permutations of orderings.
I mean, given the first element in my array, I need a list of all the elements that follow it sequentially. Then, given the second element, a list of all subsequent elements.
So, given my list: b, c and d, follow a. c and d follow b, and d follows c.
x = np.array(["a", "b", "c", "d"])
Thus, the potential conclusion is as follows:
[
["a","b"],
["a","c"],
["a","d"],
["b","c"],
["b","d"],
["c","d"],
]
I will need to do this several million times, so I am looking for an effective solution.
I tried something like:
im = np.vstack([x]*len(x))
a = np.vstack(([im], [im.T])).T
results = a[np.triu_indices(len(x),1)]
but actually it is slower than a cycle ...