- NumPy Tutorial
- NumPy - Home
- NumPy - Introduction
- NumPy - Environment
- NumPy - Ndarray Object
- NumPy - Data Types
- NumPy - Array Attributes
- NumPy - Array Creation Routines
- NumPy - Array from Existing Data
- Array From Numerical Ranges
- NumPy - Indexing & Slicing
- NumPy - Advanced Indexing
- NumPy - Broadcasting
- NumPy - Iterating Over Array
- NumPy - Array Manipulation
- NumPy - Binary Operators
- NumPy - String Functions
- NumPy - Mathematical Functions
- NumPy - Arithmetic Operations
- NumPy - Statistical Functions
- Sort, Search & Counting Functions
- NumPy - Byte Swapping
- NumPy - Copies & Views
- NumPy - Matrix Library
- NumPy - Linear Algebra
- NumPy - Matplotlib
- NumPy - Histogram Using Matplotlib
- NumPy - I/O with NumPy
- NumPy Useful Resources
- NumPy Compiler
- NumPy - Quick Guide
- NumPy - Useful Resources
- NumPy - Discussion
numpy.split
This function divides the array into subarrays along a specified axis. The function takes three parameters.
numpy.split(ary, indices_or_sections, axis)
Where,
Sr.No. | Parameter & Description |
---|---|
1 | ary Input array to be split |
2 | indices_or_sections Can be an integer, indicating the number of equal sized subarrays to be created from the input array. If this parameter is a 1-D array, the entries indicate the points at which a new subarray is to be created. |
3 | axis Default is 0 |
Example
import numpy as np a = np.arange(9) print 'First array:' print a print '\n' print 'Split the array in 3 equal-sized subarrays:' b = np.split(a,3) print b print '\n' print 'Split the array at positions indicated in 1-D array:' b = np.split(a,[4,7]) print b
Its output is as follows −
First array: [0 1 2 3 4 5 6 7 8] Split the array in 3 equal-sized subarrays: [array([0, 1, 2]), array([3, 4, 5]), array([6, 7, 8])] Split the array at positions indicated in 1-D array: [array([0, 1, 2, 3]), array([4, 5, 6]), array([7, 8])]
numpy_array_manipulation.htm
Advertisements