Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Numpy exercise
  • pandas
  • Matplotlib
  • Data visulisation
  • EDA
  • Machin Learning
  • Deep Learning
  • NLP
  • Data science
  • ML Tutorial
  • Computer Vision
  • ML project
Open In App
Next Article:
numpy.array_str() in Python
Next article icon

Python | numpy.array_split() method

Last Updated : 17 Sep, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report

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.




# 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 :




# 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]])]



Next Article
numpy.array_str() in Python

J

Jitender_1998
Improve
Article Tags :
  • Python
  • Python numpy-arrayManipulation
  • Python-numpy
Practice Tags :
  • python

Similar Reads

  • Python | Numpy fromarrays() method
    With the help of numpy.core.fromarrays() method, we can create the record array by using the list of different arrays by using numpy.core.fromarrays() method. Syntax : numpy.core.fromarrays([li1, li2....], metadata) Return : Return the record of an array. Example #1 : In this example we can see that
    1 min read
  • numpy.array_str() in Python
    numpy.array_str()function is used to represent the data of an array as a string. The data in the array is returned as a single string. This function is similar to array_repr, the difference being that array_repr also returns information on the kind of array and its data type. Syntax : numpy.array_st
    2 min read
  • Python Lists VS Numpy Arrays
    Here, we will understand the difference between Python List and Python Numpy array. What is a Numpy array?NumPy is the fundamental package for scientific computing in Python. Numpy arrays facilitate advanced mathematical and other types of operations on large numbers of data. Typically, such operati
    7 min read
  • Python | Numpy numpy.ndarray.__rshift__()
    With the help of numpy.ndarray.__rshift__() method, we can get the elements that is right shifted by the value that is provided as a parameter in numpy.ndarray.__rshift__() method. Syntax: ndarray.__rshift__($self, value, /) Return: self>>value Example #1 : In this example we can see that ever
    1 min read
  • numpy.array_repr() in Python
    numpy.array_repr()function is used to convert an array to a string. Syntax : numpy.array_repr(arr, max_line_width=None, precision=None, suppress_small=None) Parameters : arr : [array_like] Input array. max_line_width : [int, optional] The maximum number of columns the string should span. Newline cha
    2 min read
  • NumPy Array in Python
    NumPy (Numerical Python) is a powerful library for numerical computations in Python. It is commonly referred to multidimensional container that holds the same data type. It is the core data structure of the NumPy library and is optimized for numerical and scientific computation in Python. Table of C
    2 min read
  • Python | Numpy numpy.ndarray.__sub__()
    With the help of Numpy numpy.ndarray.__sub__(), We can subtract a particular value that is provided as a parameter in the ndarray.__sub__() method. Value will be subtracted to each and every element in a numpy array. Syntax: ndarray.__sub__($self, value, /) Return: self-value Example #1 : In this ex
    1 min read
  • numpy.vsplit() function | Python
    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] A
    2 min read
  • Python - Numpy fromrecords() method
    numpy.fromrecords() method is a powerful tool in the NumPy library that allows you to create structured arrays from a sequence of tuples or other array-like objects. Let's understand the help of an example: [GFGTABS] Python import numpy as np # Define a list of records records = [(1, 'Alice'
    2 min read
  • Numpy MaskedArray asarray() method | Python
    numpy.ma.asarray() function is used when we want to convert input to a masked array of the given data-type. No copy is performed if the input is already a ndarray. If arr is a subclass of MaskedArray, a base class MaskedArray is returned. Syntax : numpy.ma.asarray(arr, dtype=None, order=None) Parame
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences