← Back to Pandas Course | Chapter 5: Data Cleaning | Lesson 7 of 7

Outlier Detection की बुनियादी बातें

Outliers बाकी से दूर values हैं; IQR rule इन्हें flag करने का एक simple तरीका है।

In this page:

  1. Outlier Detection Basics
Syntax
python
q1 = df["column"].quantile(0.25)
q3 = df["column"].quantile(0.75)
iqr = q3 - q1
outliers = df[(df["column"] < q1 - 1.5 * iqr) | (df["column"] > q3 + 1.5 * iqr)]

Outlier Detection Basics

पहली और तीसरी quartiles compute करें, फिर interquartile range IQR = Q3 - Q1। Q1 - 1.5*IQR से नीचे या Q3 + 1.5*IQR से ऊपर की values आमतौर पर outliers की तरह flag होती हैं।

Z-scores एक और approach है।

हटाने से पहले outliers investigate करें, क्योंकि ये real हो सकती हैं।

Note: quantile(0.25) और quantile(0.75) quartiles देते हैं।

उदाहरण: Outlier detection basics

python
import pandas as pd

s = pd.Series([10, 12, 11, 13, 12, 95])
q1, q3 = s.quantile(0.25), s.quantile(0.75)
iqr = q3 - q1
low, high = q1 - 1.5 * iqr, q3 + 1.5 * iqr
print("bounds:", low, high)
print(s[(s < low) | (s > high)])

# Output:
# bounds: 9.0 15.0
# 5    95
# dtype: int64
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. यह check किए बिना outliers delete करना कि ये genuine हैं या नहीं
  2. छोटे samples पर IQR rule apply करना
  3. outliers को errors से confuse करना
चैप्टर सारांश
  • Outliers bulk से दूर हैं
  • IQR rule 1.5 times IQR इस्तेमाल करता है
  • Drop करने से पहले investigate करें
  • quantile quartiles देता है
🔒

Chapter Quiz — Complete all 7 topics to unlock

0/7 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.