dtype क्या है
dtype attribute report करता है कि हर element किस तरह का number है।
In this page:
Syntax
arr.dtype
arr.dtype.name
dtype
dtype एक object है जो element type describe करता है, name, kind, और itemsize जैसी properties के साथ। यह creation पर set होता है और astype से बदला जाता है। जल्दी dtype check करना integer division या overflow से आने वाली कई subtle bugs रोकता है।
Note:
int64 जैसी एक clean string पाने के लिए arr.dtype.name print करें।
उदाहरण: dtype
import numpy as np
a = np.array([1, 2, 3])
print(a.dtype, a.dtype.name)
a[0] = 9.9
print("after assigning 9.9:", a)
print(a.astype(np.float64).dtype)
# Output:
# int64 int64
# after assigning 9.9: [9 2 3]
# float64
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. #}
आम गलतियां
- यह मान लेना कि values बदलने पर dtype automatically बदलता है
- यह भूल जाना कि int arrays assigned floats truncate करते हैं
- dtype को Python type से confuse करना
चैप्टर सारांश
- dtype element type describe करता है
- एक int array को assign की गई values truncate होती हैं
- astype एक converted copy बनाता है
- dtype.name एक readable label देता है