w3resource logo
Python Exercises

Python NumPy: How to add an extra column to an numpy array

Python NumPy: Array Object Exercise-86 with Solution

Write a Python program to how to add an extra column to an numpy array.

Sample Solution:-

Python Code:

import numpy as np
x = np.array([[10,20,30], [40,50,60]])
y = np.array([[100], [200]])
print(np.append(x, y, axis=1))

Sample Output:

[[ 10  20  30 100]                                                     
 [ 40  50  60 200]]

Python Code Editor:

import numpy as np
x = np.array([[10,20,30], [40,50,60]])
y = np.array([[100], [200]])
print(np.append(x, y, axis=1))

Improve this sample solution and post your code through Disqus