0

I have two lists that contain thousands of numpy arrays.

I would like to find an efficient way to concatenate each numpy array that is located at the same index.

For example:

list1 = [[0,0,2],[0,5,6]]
list2 = [[3,4,6],[1,7,8]]

final_list = [[0,0,2,0,5,6],[3,4,6,1,7,8]]

I need to do this for a list of size 3300.

1
  • 2
    You gave us a pure list example, but talk about lists of arrays. Please be consistent. A list answer will be different from a numpy array one. Commented Nov 28, 2017 at 20:28

1 Answer 1

1
import numpy as np

list1 = [np.array([0,0,2]),np.array([0,5,6])]
list2 = [np.array([3,4,6]),np.array([1,7,8])]

final_list = np.hstack((list1, list2))
print final_list
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.