1

EDIT: Please note that the question has 4 NumPy arrays, and thus might be much more difficult to merge, which is why I asked the queston in first place.

I want to generate all possible combinations of 4 NumPy arrays, but cannot find a suitable Pythonic way to do this. For example these are the arrays:

w = np.array([-0.75, -0.25, 0, 0.25, 0.75])
x = np.array([-0.75, -0.25, 0, 0.25, 0.75])
y = np.array([-0.75, -0.25, 0, 0.25, 0.75])
z = np.array([-0.75, -0.25, 0, 0.25, 0.75])

Now I want to generate a (625,4) dimensional array with all possible combinations of the elements taken from the 4 arrays i.e elements from x will populate 1st column, y 2nd column and so on but all possible combinations should be made, something like:

000
001
010
011
100
101
110
111

I could not figure out how to do this with np.meshgrid as there are too many dimensions to visualise.

DuttaA
  • 903
  • 4
  • 10
  • 24
  • @coldspeed how is this duplicate? I clearly mentioned I could not visualise more than 2 dimensions hence the question in the first place. – DuttaA Apr 13 '19 at 01:38
  • If you go through the post, you'll find the second answer there has functions to merge two (or more) 1D arrays. – cs95 Apr 13 '19 at 01:43

0 Answers0