summaryrefslogtreecommitdiff
path: root/doc/source/user/quickstart.rst
diff options
context:
space:
mode:
Diffstat (limited to 'doc/source/user/quickstart.rst')
-rw-r--r--doc/source/user/quickstart.rst27
1 files changed, 16 insertions, 11 deletions
diff --git a/doc/source/user/quickstart.rst b/doc/source/user/quickstart.rst
index 65840c724..f69eb3ace 100644
--- a/doc/source/user/quickstart.rst
+++ b/doc/source/user/quickstart.rst
@@ -713,27 +713,32 @@ Several arrays can be stacked together along different axes::
The function `column_stack`
stacks 1D arrays as columns into a 2D array. It is equivalent to
-`vstack` only for 1D arrays::
+`hstack` only for 2D arrays::
>>> from numpy import newaxis
- >>> np.column_stack((a,b)) # With 2D arrays
+ >>> np.column_stack((a,b)) # with 2D arrays
array([[ 8., 8., 1., 8.],
[ 0., 0., 0., 4.]])
>>> a = np.array([4.,2.])
- >>> b = np.array([2.,8.])
- >>> a[:,newaxis] # This allows to have a 2D columns vector
+ >>> b = np.array([3.,8.])
+ >>> np.column_stack((a,b)) # returns a 2D array
+ array([[ 4., 3.],
+ [ 2., 8.]])
+ >>> np.hstack((a,b)) # the result is different
+ array([ 4., 2., 3., 8.])
+ >>> a[:,newaxis] # this allows to have a 2D columns vector
array([[ 4.],
[ 2.]])
>>> np.column_stack((a[:,newaxis],b[:,newaxis]))
- array([[ 4., 2.],
+ array([[ 4., 3.],
+ [ 2., 8.]])
+ >>> np.hstack((a[:,newaxis],b[:,newaxis])) # the result is the same
+ array([[ 4., 3.],
[ 2., 8.]])
- >>> np.vstack((a[:,newaxis],b[:,newaxis])) # The behavior of vstack is different
- array([[ 4.],
- [ 2.],
- [ 2.],
- [ 8.]])
-For arrays of with more than two dimensions,
+On the other hand, the function `row_stack` is equivalent to `vstack`
+for any input arrays.
+In general, for arrays of with more than two dimensions,
`hstack` stacks along their second
axes, `vstack` stacks along their
first axes, and `concatenate`