python - numpy vstack vs. column_stack -


what difference between numpy vstack , column_stack. reading through documentation, looks if column_stack implementation of vstack 1d arrays. more efficient implementation? otherwise, cannot find reason having vstack.

i think following code illustrates difference nicely:

>>> np.vstack(([1,2,3],[4,5,6])) array([[1, 2, 3],        [4, 5, 6]]) >>> np.column_stack(([1,2,3],[4,5,6])) array([[1, 4],        [2, 5],        [3, 6]]) >>> np.hstack(([1,2,3],[4,5,6])) array([1, 2, 3, 4, 5, 6]) 

i've included hstack comparison well. notice how column_stack stacks along second dimension whereas vstack stacks along first dimension. equivalent column_stack following hstack command:

>>> np.hstack(([[1],[2],[3]],[[4],[5],[6]])) array([[1, 4],        [2, 5],        [3, 6]]) 

i hope can agree column_stack more convenient.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

qt - Errors in generated MOC files for QT5 from cmake -