0

I'm trying to combine 4 arrays into one in the following fashion

a = ([1,5,9])
b = ([2,6,10])
c = ([3,7,11])
d = ([4,8,12])

combination = [[1,2,3,4][5,6,7,8][9,10,11,12]]

any help would be greatly appreaciated

4
  • What was the problem when you tried to do this? Commented Mar 10, 2021 at 18:57
  • 1
    np.stack((a,b,c,d)).T Commented Mar 10, 2021 at 18:57
  • 1
    Does this answer your question? Concatenate two NumPy arrays vertically Commented Mar 10, 2021 at 18:58
  • What's wrong with the obvious np.array(combination)? Commented Mar 10, 2021 at 19:39

1 Answer 1

1
import numpy as np

a = ([1,5,9])
b = ([2,6,10])
c = ([3,7,11])
d = ([4,8,12])

print (np.stack((a,b,c,d), axis=-1))

Output:

[[ 1  2  3  4]
 [ 5  6  7  8]
 [ 9 10 11 12]]
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.