Repeat last column in numpy array
One possible solution:
a = np.hstack((arr, np.tile(arr[:, [-1]], 2)))
print (a)
[[1 2 3 3 3]
[0 0 0 0 0]
[0 2 1 1 1]]
Broadcasting is often efficient.
import numpy as np
A = np.random.randint(0, 100, (1000, 1000))
np.hstack((A, np.broadcast_to(A[:, -1][:, None], (A.shape[1], n))))
Some benchmarking if performance is an issue:
n = 1000
%timeit np.hstack((A, np.broadcast_to(A[:, -1][:, None], (A.shape[1], n)))) # 3.06 ms
%timeit np.hstack((A, np.tile(A[:, [-1]], n))) # 9.33 ms
%timeit np.repeat(A, [1]*(A.shape[1]-1) +[n], axis=1) # 12.9 ms