A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.geeksforgeeks.org/machine-learning/numpy-vsplit-function-python/ below:

numpy.vsplit() function | Python - GeeksforGeeks

numpy.vsplit() function | Python

Last Updated : 22 Apr, 2020

numpy.vsplit()

function split an array into multiple sub-arrays vertically (row-wise). 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(arr, indices_or_sections) Parameters : arr : [ndarray] Array to be divided into sub-arrays. indices_or_sections : [int or 1-D array] If indices_or_sections is an integer, N, the array will be divided into N equal arrays along axis. If indices_or_sections is a 1-D array of sorted integers, the entries indicate where along axis the array is split Return : [ndarray] A list of sub-arrays.
Code #1 : Python3
# Python program explaining
# numpy.vsplit() function

# importing numpy as geek 
import numpy as geek

arr = geek.arange(9.0).reshape(3, 3)

gfg = geek.vsplit(arr, 1)

print (gfg)
Output :
[array([[ 0.,  1.,  2.],
       [ 3.,  4.,  5.],
       [ 6.,  7.,  8.]])]
  Code #2 : Python3
# Python program explaining
# numpy.vsplit() function

# importing numpy as geek 
import numpy as geek

arr = geek.arange(36.0).reshape(6, 6)

gfg = geek.vsplit(arr, 2)

print (gfg)
Output :
[array([[  0.,   1.,   2.,   3.,   4.,   5.],
       [  6.,   7.,   8.,   9.,  10.,  11.],
       [ 12.,  13.,  14.,  15.,  16.,  17.]]), array([[ 18.,  19.,  20.,  21.,  22.,  23.],
       [ 24.,  25.,  26.,  27.,  28.,  29.],
       [ 30.,  31.,  32.,  33.,  34.,  35.]])]


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4