NumPy ऑनलाइन चलाएँ

NumPy Array को Filter करना

Comparison हर element के लिए True या False बनाता है।

NumPy Array को Filter करना क्या है?

Comparison हर element के लिए True या False बनाता है।

Boolean mask से values चुनें।

इसका उपयोग कब करें?

  • कई मानों पर vectorized गणना करें।
  • Arrays, matrices और scientific data संसाधित करें।
  • Data science और machine learning के लिए data तैयार करें।

उदाहरण कोड

कोड चलाएँ →
main.py
import numpy as np

scores = np.array([64, 82, 91, 73, 88])
passing = scores[scores >= 80]

print(passing)

अपेक्षित आउटपुट

[82 91 88]

यह कैसे काम करता है

Mask को index की तरह लगाने पर True positions रहती हैं; conditions को parentheses में & या | से जोड़ें।

मान बदलें और Python इंस्टॉल किए बिना CodeUtility ऑनलाइन Python कंपाइलर में प्रोग्राम चलाएँ।

अभ्यास के कार्य

बड़े dataset पर जाने से पहले input बदलें और edge cases की जाँच करें।

  1. Shape और dtype बदलकर देखें।
  2. Negative, decimal और missing values जाँचें।
  3. बड़े array पर execution time मापें।
Python IDE में चलाएँ →