Let’s say I have a NumPy array, a:
a
a = np.array([ [1, 2, 3], [2, 3, 4] ])
And I would like to add a column of ze
One way, using hstack, is:
b = np.hstack((a, np.zeros((a.shape[0], 1), dtype=a.dtype)))