Concatenate two arrays (lists) in Python


Set up arrays

list_one = [7, 6, 5]
list_two = [4, 3, 2]

Concatenate arrays horizontally

#horizontally
merged_list = list_one + list_two
merged_list
[7, 6, 5, 4, 3, 2]

Concatenate arrays vertically

#vertically
                import numpy as np
                np.vstack((list_one,list_two))
                
array([[7, 6, 5], [4, 3, 2]])


Copyright © Erik Rood 2017