Split Numpy Array

Split means to break/ slash an array into multiple arrays. To split an array, use the array_split() method. The following is the syntax:

Here, arr_name is the name of the array, split_num is the count of splits.

In this lesson, we will learn how to,

  • Split a 1D array
  • Access a split 1D array
  • Split a 2D array and how to access

Split a 1D array

As shown above, to split an array in Numpy, we use the array_split() method. Herein, we will split a 1D array. Let us see an example of splitting a 1D array:

Output

Access a split 1D array

To access a split One-Dimensional array, use the index number for the array element you want to display. Let us see an example to learn how to access a splitter 1D array:

Output

Split a 2D array and access

The split result will be a 2D array, for example, if a 2D array is split into two, there will be two 2D arrays as a result. Let us see an example of splitting a 2D array:

Output

If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.

For Videos, Join Our YouTube Channel: Join Now


Read More:

Joining Numpy Arrays
Search a Numpy Array for a value
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading