Skip to main content

NumPy Vertical Splitting: numpy.vsplit() function

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

Syntax:

numpy.vsplit(array, sections)

Examples:

For 2-D Array:

import numpy as np
a=np.array([[1,2],[3,4],[5,6],[7,8]])
b=np.vsplit(a,4)
print(b)

Output:

[array([[1, 2]]), array([[3, 4]]), array([[5, 6]]), array([[7, 8]])]

Note: Vertical Splitting is not possible in a 1-D Array. vsplit() is alternate to vstack().

Submitted by devanshi.srivastava on September 7, 2021

Devanshi, is working as a Data Scientist with iVagus. She has expertise in Python, NumPy, Pandas and other data science technologies.

About

At ProgramsBuzz, you can learn, share and grow with millions of techie around the world from different domain like Data Science, Software Development, QA and Digital Marketing. You can ask doubt and get the answer for your queries from our experts.