When should I use hstack/vstack vs append vs concatenate vs column_stack?

If you have two matrices, you’re good to go with just hstack and vstack:

If you’re stacking a matrice and a vector, hstack becomes tricky to use, so column_stack is a better option:

If you’re stacking two vectors, you’ve got three options:

And concatenate in its raw form is useful for 3D and above, see
my article Numpy Illustrated for details.

Leave a Comment