# NumPy Array manipulation: vsplit() function

## numpy.vsplit() function

The vsplit() function is used to split an array into multiple sub-arrays vertically (row-wise).

Note: vsplit is equivalent to split with axis=0 (default), the array is always split along the first axis regardless of the array dimension.

Syntax:

`numpy.vsplit(ary, indices_or_sections)`

Version: 1.15.0

Parameter:

Name Description Required /
Optional
ary Input array. Required
indices_or_sections Indices or sections. Required

Return value:

Example-1: numpy.vsplit function

``````>>> import numpy as np
>>> a = np.arange(20.0).reshape(4,5)
>>> a
array([[  0.,   1.,   2.,   3.,   4.],
[  5.,   6.,   7.,   8.,   9.],
[ 10.,  11.,  12.,  13.,  14.],
[ 15.,  16.,  17.,  18.,  19.]])
>>> np.vsplit(a, 2)
[array([[ 0.,  1.,  2.,  3.,  4.],
[ 5.,  6.,  7.,  8.,  9.]]), array([[ 10.,  11.,  12.,  13.,  14.],
[ 15.,  16.,  17.,  18.,  19.]])]
``````

Pictorial Presentation:

Example-2: numpy.vsplit function

``````>>> import numpy as np
>>> np.vsplit(a, np.array([2, 5]))
[array([[ 0.,  1.,  2.,  3.,  4.],
[ 5.,  6.,  7.,  8.,  9.]]), array([[ 10.,  11.,  12.,  13.,  14.],
[ 15.,  16.,  17.,  18.,  19.]]), array([], shape=(0, 5), dtype=float64)]
``````

Example-3: numpy.vsplit function

``````>>> import numpy as np
>>> a = np.arange(12.0).reshape(2,3,2)
>>> a
array([[[  0.,   1.],
[  2.,   3.],
[  4.,   5.]],

[[  6.,   7.],
[  8.,   9.],
[ 10.,  11.]]])
>>> np.vsplit(a, 2)
[array([[[ 0.,  1.],
[ 2.,  3.],
[ 4.,  5.]]]), array([[[  6.,   7.],
[  8.,   9.],
[ 10.,  11.]]])]
``````

Python - NumPy Code Editor:

Previous: hsplit()
Next: Tiling arrays tile()

﻿