0

I'm not sure what the proper terminology is for this but I would like to combine two arrays such that the resulting array has paired each item from A with each item from B:

A = [1, 2, 3]
B = [1, 2, 3]

result = [[1,1],
          [1,2],
          [1,3],
          [2,1],
          [2,2],
          [2,3],
          [3,1],
          [3,2],
          [3,3]]

Is there a numpy method for accomplishing this or do I need to generate a for loop and build a whole new array?

2

1 Answer 1

2

Generate that using:

[(x,y) for x in A for y in B]
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.