ndarray के Basics
ndarray numbers का NumPy का grid है; यह एक line, एक table, या values का एक cube भी हो सकता है।
In this page:
Syntax
import numpy as np
arr = np.array([value1, value2, value3])
arr.shape
arr.dtype
ndarray Basics
ndarray एक homogeneous, fixed-size, N-dimensional container है। एक 1-D array एक vector जैसा है, एक 2-D array एक matrix जैसा है, और higher dimensions same तरीके से काम करते हैं। हर array अपना shape और data type जानता है।
Note:
Equal length वाली Nested lists एक 2-D array बनती हैं; ragged lists नहीं बनतीं।
उदाहरण: ndarray basics
import numpy as np
v = np.array([1, 2, 3])
m = np.array([[1, 2, 3], [4, 5, 6]])
print("Vector:", v, "shape", v.shape)
print("Matrix:")
print(m)
print("Matrix shape:", m.shape)
# Output:
# Vector: [1 2 3] shape (3,)
# Matrix:
# [[1 2 3]
# [4 5 6]]
# Matrix shape: (2, 3)
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. #}
आम गलतियां
- Ragged nested lists pass करना और एक clean 2-D array की उम्मीद करना
- array को खुद एक Python list से confuse करना
- यह भूल जाना कि NumPy 0 से index करता है
चैप्टर सारांश
- ndarray homogeneous और N-dimensional है
- Nested lists multi-dimensional arrays बनाती हैं
- Arrays .shape और .dtype expose करते हैं
- Indexing 0 से शुरू होती है
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: