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

dtype क्या है

dtype attribute report करता है कि हर element किस तरह का number है।

In this page:

  1. dtype
Syntax
python
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

python
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. #}
आम गलतियां
  1. यह मान लेना कि values बदलने पर dtype automatically बदलता है
  2. यह भूल जाना कि int arrays assigned floats truncate करते हैं
  3. dtype को Python type से confuse करना
चैप्टर सारांश
  • dtype element type describe करता है
  • एक int array को assign की गई values truncate होती हैं
  • astype एक converted copy बनाता है
  • dtype.name एक readable label देता है
🔒

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.