size क्या है
size array में elements की total count है, चाहे इसकी कितनी भी dimensions हों।
In this page:
Syntax
arr.size
size
size सारी shape entries को साथ multiply करता है। एक (3, 4) array का size 12 है। यह len() से अलग है, जो सिर्फ पहली axis की length return करता है।
Note:
यह check करने के लिए arr.size इस्तेमाल करें कि एक reshape target exactly same संख्या elements hold करता है।
उदाहरण: size
import numpy as np
m = np.zeros((3, 4))
print("size:", m.size)
print("len:", len(m))
print("shape product:", m.shape[0] * m.shape[1])
# Output:
# size: 12
# len: 3
# shape product: 12
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. #}
आम गलतियां
- len() इस्तेमाल करना और total element count की उम्मीद करना
- एक ऐसे shape में reshape करना जिसका product size से अलग हो
- size को एक function की तरह call करना
चैप्टर सारांश
- size elements की total संख्या है
- यह shape का product है
- len सिर्फ पहली axis return करता है
- यह एक attribute है