A RetroSearch Logo

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

Search Query:

Showing content from https://www.geeksforgeeks.org/python/python-numpy-array_split-method/ below:

Python | numpy.array_split() method - GeeksforGeeks

Python | numpy.array_split() method

Last Updated : 17 Sep, 2019

With the help of

numpy.array_split()

method, we can get the splitted array of having different dimensions by using

numpy.array_split()

method.

Syntax : numpy.array_split() Return : Return the splitted array of one dimension.
Example #1 :

In this example we can see that by using

numpy.array_split()

method, we are able to split the array in the number of subarrays by passing it as a parameter.

Python3 1=1
# import numpy
import numpy as np

array = np.arange(9)

# using numpy.array_split() method
gfg = np.array_split(array, 4)

print(gfg)
Output :
[array([0, 1, 2]), array([3, 4]), array([5, 6]), array([7, 8])]
Example #2 : Python3 1=1
# import numpy
import numpy as np

array = [[1, 2, 3],
         [4, 5, 6],
         [7, 8, 9]]

# using numpy.array_split() method
gfg = np.array_split(array, 3)

print(gfg)
Output :
[array([[1, 2, 3]]), array([[4, 5, 6]]), array([[7, 8, 9]])]


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