← Back to NumPy Course | Chapter 5: Array Manipulation | Lesson 6 of 7

split() से Array तोड़ना

split() एक array को कई छोटे arrays में काटता है।

In this page:

  1. split()
Syntax
python
np.split(arr, sections)
np.split(arr, [index1, index2])

split()

np.split एक array को equal parts में divide करता है, या अगर आप एक list pass करें specific index positions पर। यह arrays की एक list return करता है। np.array_split unequal parts allow करता है जब size evenly divide न हो।

Note: np.split uneven divisions के लिए एक error raise करता है; इसकी बजाय array_split इस्तेमाल करें।

उदाहरण: split()

python
import numpy as np

a = np.arange(9)
print(np.split(a, 3))
print(np.split(a, [2, 5]))
print(np.array_split(np.arange(7), 3))

# Output:
# [array([0, 1, 2]), array([3, 4, 5]), array([6, 7, 8])]
# [array([0, 1]), array([2, 3, 4]), array([5, 6, 7, 8])]
# [array([0, 1, 2]), array([3, 4]), array([5, 6])]
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. एक ऐसी count में split करना जो evenly divide न हो
  2. यह भूल जाना कि result एक list है
  3. split points को sizes से confuse करना
चैप्टर सारांश
  • split arrays की एक list return करता है
  • एक int मतलब equal parts
  • एक list मतलब split indices
  • array_split uneven sizes allow करता है
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 topics done

Complete these topics first:

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.