Masked Arrays क्या हैं
Masked arrays आपको bad या missing values hide करने देते हैं ताकि calculations इन्हें skip करें।
In this page:
Syntax
masked = np.ma.masked_array(data, mask=boolean_mask)
masked.mean()
Masked Arrays
np.ma.masked_array data को एक boolean mask से pair करता है; masked entries को mean और sum जैसे functions ignore करते हैं। masked_where और masked_invalid जैसे helpers conditions से masks बनाते हैं। masked values replace करने के लिए .filled() इस्तेमाल करें।
Note:
Mask में एक True मतलब value hidden है, एक boolean index के opposite।
उदाहरण: Masked arrays
import numpy as np
data = np.array([10, -999, 30, -999, 50])
m = np.ma.masked_where(data == -999, data)
print(m)
print("mean:", m.mean())
print(m.filled(0))
# Output:
# [10 -- 30 -- 50]
# mean: 30.0
# [10 0 30 0 50]
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. #}
आम गलतियां
- mask को backwards पढ़ना
- यह भूल जाना कि normal functions masks respect नहीं करते
- एक plain array में convert करके mask खोना
चैप्टर सारांश
- Masked entries ignore होती हैं
- Mask में True एक value hide करता है
- masked_where masks बनाता है
- filled masked values replace करता है
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: