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