Home Python C Language C ++ HTML 5 CSS Javascript Java Kotlin SQL DJango Bootstrap React.js R C# PHP ASP.Net Numpy Dart Pandas Digital Marketing

Learn Array Split

In NumPy, the numpy.split() function is used to split an array into multiple sub-arrays along a specified axis. It allows you to divide an array into smaller arrays of equal size (if possible) or based on specified split points.


The syntax for numpy.split() is as follows:

numpy.split(array, indices_or_sections, axis=0)


Here's an example of using numpy.split():

import numpy as np
arr = np.arange(10)
# Split arr into 5 equal-sized sub-arrays
sub_arrays = np.split(arr, 5)
print(sub_arrays)

Output

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

numpy.split() is useful for dividing arrays into smaller parts, which can be helpful for various data processing tasks.






Advertisement





Q3 Schools : India


Online Complier

HTML 5

Python

java

C++

C

JavaScript

Website Development

HTML

CSS

JavaScript

Python

SQL

Campus Learning

C

C#

java