w3resource logo

:

Python Exercises

Python NumPy: Concatenate two 2-dimensional arrays

Python NumPy: Array Object Exercise-58 with Solution

Write a Python program to concatenate two 2-dimensional arrays.
Sample arrays: ([[0, 1, 3], [5, 7, 9]], [[0, 2, 4], [6, 8, 10]]

Sample Solution:-

Python Code:

import numpy as np
a = np.array([[0, 1, 3], [5, 7, 9]])
b = np.array([[0, 2, 4], [6, 8, 10]])
c = np.concatenate((a, b), 1)
print(c)

Sample Output:

[[ 0  1  3  0  2  4]                                                   
 [ 5  7  9  6  8 10]] 

Python Code Editor:

Improve this sample solution and post your code through Disqus