← Back to NumPy Course | Chapter 3: Array Attributes | Lesson 2 of 6

ndim क्या है

ndim count करता है एक array की कितनी dimensions (axes) हैं।

In this page:

  1. ndim
Syntax
python
arr.ndim

ndim

ndim values की एक line के लिए 1 है, एक table के लिए 2, tables के एक stack के लिए 3। यह हमेशा shape tuple की length के बराबर है। ndim जानना आपको सही indexing और axis arguments चुनने में मदद करता है।

Note: np.array से wrapped एक single number का ndim 0 है।

उदाहरण: ndim

python
import numpy as np

print(np.array(5).ndim)
print(np.array([1, 2, 3]).ndim)
print(np.array([[1, 2], [3, 4]]).ndim)
print(np.zeros((2, 3, 4)).ndim)

# Output:
# 0
# 1
# 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. #}
आम गलतियां
  1. ndim को array की length से confuse करना
  2. dimensions और rows mix up करना
  3. यह भूल जाना कि scalars की zero dimensions होती हैं
चैप्टर सारांश
  • ndim axes की संख्या है
  • यह len(shape) के बराबर है
  • Scalars का ndim 0 है
  • यह एक method नहीं attribute है
🔒

Chapter Quiz — Complete all 6 topics to unlock

0/6 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.